Class: SearchCopGrammar::AnywhereExpression

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/search_cop_grammar.rb

Instance Attribute Summary

Attributes inherited from BaseNode

#query_info, #query_options

Instance Method Summary collapse

Methods inherited from BaseNode

#collection_for, #elements

Instance Method Details

#evaluateObject



89
90
91
92
93
94
95
# File 'lib/search_cop_grammar.rb', line 89

def evaluate
  queries = query_info.scope.reflection.default_attributes.keys.collect { |key| collection_for key }.select { |collection| collection.compatible? text_value }.collect { |collection| collection.matches text_value }

  raise SearchCop::NoSearchableAttributes if queries.empty?

  queries.flatten.inject(:or)
end