Class: Conditions::OrCondition
- Inherits:
-
BaseCondition
- Object
- BaseCondition
- Conditions::OrCondition
- Defined in:
- lib/conditions.rb
Overview
Checks if either or both of two conditions are true
Instance Method Summary collapse
- #apply(value) ⇒ true, false
-
#initialize(predicate) ⇒ OrCondition
constructor
A new instance of OrCondition.
Constructor Details
#initialize(predicate) ⇒ OrCondition
Returns a new instance of OrCondition.
102 103 104 105 106 107 |
# File 'lib/conditions.rb', line 102 def initialize(predicate) raise ConditionError, 'Or condition predicate must be an array of conditions' unless predicate.is_a?(Array) && predicate.length > 1 predicate.map! { |x| Object.const_get("Conditions::#{x['class']}").new(x['predicate']) } super(predicate) end |
Instance Method Details
#apply(value) ⇒ true, false
113 114 115 |
# File 'lib/conditions.rb', line 113 def apply(value) @predicate.map { |x| x.apply(value) }.any? end |