class Conditions::AndCondition
Checks if two conditions are true
Public Class Methods
new(predicate)
click to toggle source
@param [Array] predicate An array of Hashes representating conditions (Greater than length 2)
Calls superclass method
Conditions::BaseCondition::new
# 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
Public Instance Methods
apply(value)
click to toggle source
@param [Any] value @return [true] if value
matches all conditions @return [false] if value
does not match one condition
# File lib/conditions.rb, line 92 def apply(value) @predicate.map { |x| x.apply(value) }.all? end