Class: SearchCopGrammar::BaseNode

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/search_cop_grammar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#query_infoObject

Returns the value of attribute query_info.



7
8
9
# File 'lib/search_cop_grammar.rb', line 7

def query_info
  @query_info
end

Instance Method Details

#collection_for(key) ⇒ Object



21
22
23
24
25
# File 'lib/search_cop_grammar.rb', line 21

def collection_for(key)
  raise(SearchCop::UnknownColumn, "Unknown column #{key}") if query_info.scope.reflection.attributes[key].nil?

  Attributes::Collection.new query_info, key
end

#elementsObject



17
18
19
# File 'lib/search_cop_grammar.rb', line 17

def elements
  super.select { |element| element.class != Treetop::Runtime::SyntaxNode }
end

#evaluateObject



13
14
15
# File 'lib/search_cop_grammar.rb', line 13

def evaluate
  elements.collect(&:evaluate).inject(:and)
end