Module: Philiprehberger::RuleEngine::Helpers
Overview
Composite condition helpers for readable logic in condition blocks.
Instance Method Summary collapse
-
#all?(*conditions) ⇒ Boolean
Returns true if all conditions are truthy.
-
#any?(*conditions) ⇒ Boolean
Returns true if any condition is truthy.
-
#none?(*conditions) ⇒ Boolean
Returns true if no conditions are truthy.
Instance Method Details
#all?(*conditions) ⇒ Boolean
Returns true if all conditions are truthy.
11 12 13 |
# File 'lib/philiprehberger/rule_engine/helpers.rb', line 11 def all?(*conditions) conditions.all? { |c| c.is_a?(Proc) ? c.call : c } end |
#any?(*conditions) ⇒ Boolean
Returns true if any condition is truthy.
19 20 21 |
# File 'lib/philiprehberger/rule_engine/helpers.rb', line 19 def any?(*conditions) conditions.any? { |c| c.is_a?(Proc) ? c.call : c } end |
#none?(*conditions) ⇒ Boolean
Returns true if no conditions are truthy.
27 28 29 |
# File 'lib/philiprehberger/rule_engine/helpers.rb', line 27 def none?(*conditions) conditions.none? { |c| c.is_a?(Proc) ? c.call : c } end |