Module: AttrSearchable::Parser
- Defined in:
- lib/attr_searchable.rb
Class Method Summary collapse
Class Method Details
.parse(arg, model) ⇒ Object
21 22 23 |
# File 'lib/attr_searchable.rb', line 21 def self.parse(arg, model) arg.is_a?(Hash) ? parse_hash(arg, model) : parse_string(arg, model) end |
.parse_hash(hash, model) ⇒ Object
25 26 27 |
# File 'lib/attr_searchable.rb', line 25 def self.parse_hash(hash, model) AttrSearchable::HashParser.new(model).parse(hash) || raise(ParseError) end |
.parse_string(string, model) ⇒ Object
29 30 31 32 33 |
# File 'lib/attr_searchable.rb', line 29 def self.parse_string(string, model) node = AttrSearchableGrammarParser.new.parse(string) || raise(ParseError) node.model = model node.evaluate end |