Class: Torm::RulesEngine::RuleVariationHelper
- Inherits:
-
Object
- Object
- Torm::RulesEngine::RuleVariationHelper
- Defined in:
- lib/torm/rules_engine.rb
Overview
Simple helper class to add the block DSL to add_rules
Instance Method Summary collapse
- #conditions(**conditions) {|Torm::RulesEngine::RulesVariationHelper| ... } ⇒ Object
-
#initialize(engine, name, **conditions) ⇒ RuleVariationHelper
constructor
A new instance of RuleVariationHelper.
- #variation(value, policy, **conditions) ⇒ Object
Constructor Details
#initialize(engine, name, **conditions) ⇒ RuleVariationHelper
Returns a new instance of RuleVariationHelper.
50 51 52 53 54 |
# File 'lib/torm/rules_engine.rb', line 50 def initialize(engine, name, **conditions) @engine = engine @name = name @conditions = conditions end |
Instance Method Details
#conditions(**conditions) {|Torm::RulesEngine::RulesVariationHelper| ... } ⇒ Object
62 63 64 65 66 |
# File 'lib/torm/rules_engine.rb', line 62 def conditions(**conditions) engine = self.class.new(@engine, @name, **@conditions.merge(conditions)) yield engine nil end |
#variation(value, policy, **conditions) ⇒ Object
56 57 58 59 |
# File 'lib/torm/rules_engine.rb', line 56 def variation(value, policy, **conditions) @engine.add_rule(@name, value, policy, @conditions.merge(conditions)) nil end |