Class: Queries::Namespace::Autocomplete
- Inherits:
-
Query::Autocomplete
- Object
- Query
- Query::Autocomplete
- Queries::Namespace::Autocomplete
- Defined in:
- lib/queries/namespace/autocomplete.rb
Instance Attribute Summary
Attributes inherited from Query::Autocomplete
#dynamic_limit, #project_id, #query_string
Attributes inherited from Query
Instance Method Summary collapse
- #all ⇒ Object
-
#least_levenshtein ⇒ Object
override method, providing fields to search.
- #or_clauses ⇒ Object
- #short_named ⇒ Object
- #verbatim_short_named ⇒ Object
- #where_sql ⇒ String
Methods inherited from Query::Autocomplete
#autocomplete, #autocomplete_cached, #autocomplete_cached_wildcard_anywhere, #autocomplete_common_name_exact, #autocomplete_common_name_like, #autocomplete_exact_id, #autocomplete_exactly_named, #autocomplete_named, #autocomplete_ordered_wildcard_pieces_in_cached, #combine_or_clauses, #common_name_name, #common_name_table, #common_name_wild_pieces, #exactly_named, #fragments, #initialize, #integers, #match_wildcard_end_in_cached, #match_wildcard_in_cached, #named, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #pieces, #scope, #string_fragments, #wildcard_wrapped_integers, #wildcard_wrapped_years, #with_cached, #with_cached_like, #with_id, #with_project_id, #year_letter, #years
Methods inherited from Query
#alphabetic_strings, #alphanumeric_strings, base_name, #base_name, #base_query, #build_terms, #cached_facet, #end_wildcard, #levenshtein_distance, #match_ordered_wildcard_pieces_in_cached, #no_terms?, referenced_klass, #referenced_klass, #referenced_klass_except, #referenced_klass_intersection, #referenced_klass_union, #start_and_end_wildcard, #start_wildcard, #table, #wildcard_pieces
Constructor Details
This class inherits a constructor from Queries::Query::Autocomplete
Instance Method Details
#all ⇒ Object
37 38 39 |
# File 'lib/queries/namespace/autocomplete.rb', line 37 def all ::Namespace.where(where_sql).order(least_levenshtein) end |
#least_levenshtein ⇒ Object
override method, providing fields to search
33 34 35 |
# File 'lib/queries/namespace/autocomplete.rb', line 33 def least_levenshtein super([:name, :short_name, :verbatim_short_name], query_string) end |
#or_clauses ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/queries/namespace/autocomplete.rb', line 10 def or_clauses clauses = [ short_named, verbatim_short_named, with_id ].compact a = clauses.shift clauses.each do |b| a = a.or(b) end a end |
#short_named ⇒ Object
24 25 26 |
# File 'lib/queries/namespace/autocomplete.rb', line 24 def short_named table[:short_name].matches_any(terms) end |
#verbatim_short_named ⇒ Object
28 29 30 |
# File 'lib/queries/namespace/autocomplete.rb', line 28 def verbatim_short_named table[:verbatim_short_name].matches_any(terms) end |
#where_sql ⇒ String
6 7 8 |
# File 'lib/queries/namespace/autocomplete.rb', line 6 def where_sql named.or(or_clauses).to_sql end |