Class: ActiveRecordQuery::ExpressionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_query/expression_parser.rb

Overview

It evaluates an expression to execute on the context whenever a symbol or a proc is passed as value on the expression.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ExpressionParser

Returns a new instance of ExpressionParser.



5
6
7
# File 'lib/active_record_query/expression_parser.rb', line 5

def initialize(context)
  @context = context
end

Instance Method Details

#parse(expression) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/active_record_query/expression_parser.rb', line 9

def parse(expression)
  if expression.respond_to?(:each)
    expression = expression.map(&:clone)
    expression.each { |arg| parse_arg(arg) }
  else
    expression = expression.clone
    parse_arg(expression)
  end
  expression
end