Class: CommonName::Filter
- Inherits:
-
Queries::Query
- Object
- Queries::Query
- CommonName::Filter
- Defined in:
- lib/queries/common_name/filter.rb
Instance Attribute Summary collapse
-
#geographic_area_id ⇒ Object
Query variables.
-
#language_id ⇒ Object
Query variables.
-
#name ⇒ Object
Query variables.
-
#otu_id ⇒ Object
Query variables.
Attributes inherited from Queries::Query
#dynamic_limit, #options, #project_id, #query_string, #terms
Instance Method Summary collapse
- #all ⇒ ActiveRecord::Relation
- #and_clauses ⇒ ActiveRecord::Relation?
-
#initialize(options) ⇒ Filter
constructor
A new instance of Filter.
- #matching_geographic_area_id ⇒ Object
- #matching_language_id ⇒ Object
- #matching_name ⇒ Object
- #matching_otu_id ⇒ Object
- #table ⇒ Object
Methods inherited from Queries::Query
#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, #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
#initialize(options) ⇒ Filter
Returns a new instance of Filter.
9 10 11 12 13 14 |
# File 'lib/queries/common_name/filter.rb', line 9 def initialize() @name = [:name] @geographic_area_id = [:geographic_area_id] @otu_id = [:otu_id] @language_id = [:language_id] end |
Instance Attribute Details
#geographic_area_id ⇒ Object
Query variables
6 7 8 |
# File 'lib/queries/common_name/filter.rb', line 6 def geographic_area_id @geographic_area_id end |
#language_id ⇒ Object
Query variables
6 7 8 |
# File 'lib/queries/common_name/filter.rb', line 6 def language_id @language_id end |
#name ⇒ Object
Query variables
6 7 8 |
# File 'lib/queries/common_name/filter.rb', line 6 def name @name end |
#otu_id ⇒ Object
Query variables
6 7 8 |
# File 'lib/queries/common_name/filter.rb', line 6 def otu_id @otu_id end |
Instance Method Details
#all ⇒ ActiveRecord::Relation
55 56 57 58 59 60 61 62 |
# File 'lib/queries/common_name/filter.rb', line 55 def all a = and_clauses if a ::CommonName.where(a).distinct else ::CommonName.none end end |
#and_clauses ⇒ ActiveRecord::Relation?
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/queries/common_name/filter.rb', line 37 def and_clauses clauses = [ matching_otu_id, matching_geographic_area_id, matching_name, matching_language_id ].compact return nil if clauses.empty? a = clauses.shift clauses.each do |b| a = a.and(b) end a end |
#matching_geographic_area_id ⇒ Object
32 33 34 |
# File 'lib/queries/common_name/filter.rb', line 32 def matching_geographic_area_id geographic_area_id ? table[:geographic_area_id].eq(geographic_area_id) : nil end |
#matching_language_id ⇒ Object
24 25 26 |
# File 'lib/queries/common_name/filter.rb', line 24 def matching_language_id language_id ? table[:language_id].eq(language_id) : nil end |
#matching_name ⇒ Object
28 29 30 |
# File 'lib/queries/common_name/filter.rb', line 28 def matching_name name ? table[:name].eq(name) : nil end |
#matching_otu_id ⇒ Object
20 21 22 |
# File 'lib/queries/common_name/filter.rb', line 20 def matching_otu_id otu_id ? table[:otu_id].eq(otu_id) : nil end |
#table ⇒ Object
16 17 18 |
# File 'lib/queries/common_name/filter.rb', line 16 def table ::CommonName.arel_table end |