Class: BiologicalRelationship::Autocomplete
Instance Attribute Summary
#dynamic_limit, #options, #project_id, #query_string, #terms
Instance Method Summary
collapse
#alphabetic_strings, #attribute_exact_facet, #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, #build_terms, #cached, #combine_or_clauses, #common_name_name, #common_name_table, #common_name_wild_pieces, #end_wildcard, #exactly_named, #fragments, #initialize, #integers, #levenshtein_distance, #match_ordered_wildcard_pieces_in_cached, #match_wildcard_end_in_cached, #match_wildcard_in_cached, #named, #no_terms?, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #pieces, #result, #scope, #start_and_end_wildcard, #start_wildcard, #wildcard_pieces, #wildcard_wrapped_integers, #wildcard_wrapped_years, #with_cached, #with_cached_like, #with_id, #with_project_id, #year_letter, #years
Constructor Details
This class inherits a constructor from Queries::Query
Instance Method Details
#all ⇒ Scope
26
27
28
29
|
# File 'lib/queries/biological_relationship/autocomplete.rb', line 26
def all
::BiologicalRelationship.where(where_sql).order(name: :asc).limit(50)
end
|
#or_clauses ⇒ Scope
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/queries/biological_relationship/autocomplete.rb', line 11
def or_clauses
clauses = [
named,
with_inverted_name,
with_id
].compact
a = clauses.shift
clauses.each do |b|
a = a.or(b)
end
a
end
|
#table ⇒ Arel::Table
36
37
38
|
# File 'lib/queries/biological_relationship/autocomplete.rb', line 36
def table
::BiologicalRelationship.arel_table
end
|
#where_sql ⇒ Scope
6
7
8
|
# File 'lib/queries/biological_relationship/autocomplete.rb', line 6
def where_sql
with_project_id.and(or_clauses).to_sql
end
|
#with_inverted_name ⇒ Object
31
32
33
|
# File 'lib/queries/biological_relationship/autocomplete.rb', line 31
def with_inverted_name
table[:inverted_name].matches_any(terms)
end
|