Class: Descriptor::Autocomplete

Inherits:
Queries::Query show all
Defined in:
lib/queries/descriptor/autocomplete.rb

Instance Attribute Summary

Attributes inherited from Queries::Query

#dynamic_limit, #options, #project_id, #query_string, #terms

Instance Method Summary (collapse)

Methods inherited from Queries::Query

#alphabetic_strings, #autocomplete, #autocomplete_cached, #autocomplete_cached_wildcard_anywhere, #autocomplete_identifier_cached_exact, #autocomplete_identifier_cached_like, #autocomplete_ordered_wildcard_pieces_in_cached, #autocomplete_start_date, #build_terms, #cached, #combine_or_clauses, #end_wildcard, #exactly_named, #fragments, #identifier_table, #initialize, #integers, #match_ordered_wildcard_pieces_in_cached, #match_wildcard_cached, #named, #no_digits, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #pieces, #result, #scope, #simple_date, #start_and_end_wildcard, #start_wildcard, #wildcard_pieces, #wildcard_wrapped_integers, #with_id, #with_identifier, #with_identifier_like, #with_project_id, #with_start_date, #year_letter, #years

Constructor Details

This class inherits a constructor from Queries::Query

Instance Method Details

- (Scope) all

Returns:

  • (Scope)


29
30
31
# File 'lib/queries/descriptor/autocomplete.rb', line 29

def all
  ::Descriptor.where(where_sql)
end

- (Arel::Nodes::Grouping) or_clauses

Returns:

  • (Arel::Nodes::Grouping)


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/queries/descriptor/autocomplete.rb', line 9

def or_clauses
  clauses = [
    named,
    short_named,
    with_id
  ].compact

  a = clauses.shift
  clauses.each do |b|
    a = a.or(b)
  end
  a
end

- (Arel::Nodes::Matches) short_named

Returns:

  • (Arel::Nodes::Matches)


24
25
26
# File 'lib/queries/descriptor/autocomplete.rb', line 24

def short_named
  table[:short_name].matches_any(terms)
end

- (Arel::Table) table

Returns:

  • (Arel::Table)


34
35
36
# File 'lib/queries/descriptor/autocomplete.rb', line 34

def table
  ::Descriptor.arel_table
end

- (String) where_sql

Returns:

  • (String)


4
5
6
# File 'lib/queries/descriptor/autocomplete.rb', line 4

def where_sql
  with_project_id.and(or_clauses).to_sql
end