Class: Groonga::ExpressionBuildable::CallExpressionBuilder

Inherits:
ExpressionBuilder show all
Defined in:
lib/groonga/expression-builder.rb

Instance Method Summary collapse

Methods inherited from ExpressionBuilder

#&, #-, #|

Constructor Details

#initialize(function, *arguments) ⇒ CallExpressionBuilder

Returns a new instance of CallExpressionBuilder.



491
492
493
494
495
# File 'lib/groonga/expression-builder.rb', line 491

def initialize(function, *arguments)
  super()
  @function = function
  @arguments = arguments
end

Instance Method Details

#build(expression, variable) ⇒ Object



497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/groonga/expression-builder.rb', line 497

def build(expression, variable)
  expression.append_object(@function)
  @arguments.each do |argument|
    case argument
    when String, Integer, Time
      expression.append_constant(argument)
    when ::Hash
      expression.append_object(argument)
    else
      argument.build(expression, variable)
    end
  end
  expression.append_operation(Operation::CALL, @arguments.size)
end