Class: AttrSearchableGrammar::AnywhereExpression
- Inherits:
-
BaseNode
- Object
- Treetop::Runtime::SyntaxNode
- BaseNode
- AttrSearchableGrammar::AnywhereExpression
show all
- Defined in:
- lib/attr_searchable_grammar.rb
Instance Attribute Summary
Attributes inherited from BaseNode
#model
Instance Method Summary
collapse
Methods inherited from BaseNode
#collection_for, #elements
Instance Method Details
#evaluate ⇒ Object
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/attr_searchable_grammar.rb', line 86
def evaluate
keys = model.searchable_attribute_options.select { |key, value| value[:default] == true }.keys
keys = model.searchable_attributes.keys if keys.empty?
queries = keys.collect { |key| collection_for key }.select { |attribute| attribute.compatible? text_value }.collect { |attribute| attribute.matches text_value }
raise AttrSearchable::NoSearchableAttributes unless model.searchable_attributes
queries.flatten.inject(:or)
end
|