Class: BusinessFlow::Step::ConditionList

Inherits:
Object
  • Object
show all
Defined in:
lib/business_flow/step.rb

Overview

Handle some logic around conditions

Instance Method Summary collapse

Constructor Details

#initialize(if_stmts, unless_stmts) ⇒ ConditionList

Returns a new instance of ConditionList.



151
152
153
154
# File 'lib/business_flow/step.rb', line 151

def initialize(if_stmts, unless_stmts)
  @conditions = Array.wrap(if_stmts).map(&Callable.method(:new)) +
                Array.wrap(unless_stmts).map(&method(:to_unless))
end

Instance Method Details

#call(instance, inputs) ⇒ Object



156
157
158
# File 'lib/business_flow/step.rb', line 156

def call(instance, inputs)
  @conditions.all? { |cond| cond.call(instance, inputs) }
end