Class: Rulz::Evaluator::AttributeCondition
- Defined in:
- lib/rulz/evaluator.rb
Instance Method Summary collapse
- #condition(name, *args) ⇒ Object
- #evaluate ⇒ Object
-
#initialize(receiver, attribute, name, *args) ⇒ AttributeCondition
constructor
A new instance of AttributeCondition.
- #opposite_of(name, *args) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(receiver, attribute, name, *args) ⇒ AttributeCondition
Returns a new instance of AttributeCondition.
41 42 43 44 45 46 47 48 |
# File 'lib/rulz/evaluator.rb', line 41 def initialize(receiver, attribute, name, *args) @attribute = attribute @condition = Rulz::Attribute::Condition.find(receiver.class, attribute, name) super(receiver, *args) define_singleton_method attribute do @receiver.send(attribute) end end |
Instance Method Details
#condition(name, *args) ⇒ Object
50 51 52 |
# File 'lib/rulz/evaluator.rb', line 50 def condition(name, *args) Rulz::Evaluator::AttributeCondition.new(@receiver, @attribute, name, *args).evaluate end |
#evaluate ⇒ Object
58 59 60 |
# File 'lib/rulz/evaluator.rb', line 58 def evaluate instance_exec(*@args, &@condition.proc) end |
#opposite_of(name, *args) ⇒ Object
54 55 56 |
# File 'lib/rulz/evaluator.rb', line 54 def opposite_of(name, *args) not condition(name, *args) end |