Class: Rulz::Evaluator::Condition

Inherits:
Base
  • Object
show all
Defined in:
lib/rulz/evaluator.rb

Instance Method Summary collapse

Methods inherited from Base

#it

Constructor Details

#initialize(receiver, name, *args) ⇒ Condition

Returns a new instance of Condition.



19
20
21
22
# File 'lib/rulz/evaluator.rb', line 19

def initialize(receiver, name, *args)
  @condition = Rulz::Condition.find(receiver.class, name)
  super(receiver, *args)
end

Instance Method Details

#condition(name, *args) ⇒ Object



25
26
27
# File 'lib/rulz/evaluator.rb', line 25

def condition(name, *args)
  Rulz::Evaluator::Condition.new(@receiver, name, *args).evaluate
end

#evaluateObject



33
34
35
# File 'lib/rulz/evaluator.rb', line 33

def evaluate
  instance_exec(*@args, &@condition.proc)
end

#opposite_of(name, *args) ⇒ Object



29
30
31
# File 'lib/rulz/evaluator.rb', line 29

def opposite_of(name, *args)
  not condition(name, *args)
end