Class: GroongaDelta::Mapping::ExpressionEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga-delta/mapping.rb

Defined Under Namespace

Classes: Context

Instance Method Summary collapse

Constructor Details

#initialize(source_record) ⇒ ExpressionEvaluator

Returns a new instance of ExpressionEvaluator.



311
312
313
314
315
316
317
318
319
320
# File 'lib/groonga-delta/mapping.rb', line 311

def initialize(source_record)
  @context = Context.new
  context_singleton_class =
    Kernel.instance_method(:singleton_class).bind(@context).call
  source_record.each do |key, value|
    context_singleton_class.define_method(key) do
      value
    end
  end
end

Instance Method Details

#evaluate(expression) ⇒ Object



322
323
324
# File 'lib/groonga-delta/mapping.rb', line 322

def evaluate(expression)
  @context.instance_eval(expression, __FILE__, __LINE__)
end