Class: AttrSearchableGrammar::BaseNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modelObject



9
10
11
# File 'lib/attr_searchable_grammar.rb', line 9

def model
  @model || parent.model
end

Instance Method Details

#collection_for(key) ⇒ Object



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

def collection_for(key)
  raise(AttrSearchable::UnknownColumn, "Unknown column #{key}") if model.searchable_attributes[key].nil?

  Attributes::Collection.new model, key
end

#elementsObject



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

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

#evaluateObject



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

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