Class: NxtSchema::Template::OnEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/nxt_schema/template/on_evaluator.rb

Instance Method Summary collapse

Constructor Details

#initialize(condition:, value:) ⇒ OnEvaluator

Returns a new instance of OnEvaluator.



4
5
6
7
# File 'lib/nxt_schema/template/on_evaluator.rb', line 4

def initialize(condition:, value:)
  @condition = condition
  @value = value
end

Instance Method Details

#call(target = nil, *args, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/nxt_schema/template/on_evaluator.rb', line 9

def call(target = nil, *args, &block)
  return unless condition_applies?(target, *args)

  result = Callable.new(value, target, *args).call
  block.yield(result)
end