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



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

def query_info
  (@query_info ||= nil) || parent.query_info
end

#query_optionsObject



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

def query_options
  (@query_options ||= nil) || parent.query_options
end

Instance Method Details

#collection_for(key) ⇒ Object



24
25
26
27
28
# File 'lib/search_cop_grammar.rb', line 24

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



20
21
22
# File 'lib/search_cop_grammar.rb', line 20

def elements
  super.reject { |element| element.instance_of?(Treetop::Runtime::SyntaxNode) }
end

#evaluateObject



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

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