Class: Conditions::AndCondition
- Inherits:
-
BaseCondition
- Object
- BaseCondition
- Conditions::AndCondition
- Defined in:
- lib/conditions.rb
Overview
Checks if two conditions are true
Instance Method Summary collapse
- #apply(value) ⇒ true, false
-
#initialize(predicate) ⇒ AndCondition
constructor
A new instance of AndCondition.
Constructor Details
#initialize(predicate) ⇒ AndCondition
Returns a new instance of AndCondition.
81 82 83 84 85 86 |
# File 'lib/conditions.rb', line 81 def initialize(predicate) raise ConditionError, 'And 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
92 93 94 |
# File 'lib/conditions.rb', line 92 def apply(value) @predicate.map { |x| x.apply(value) }.all? end |