class Porch::StepChain
Attributes
organizer[R]
steps[R]
Public Class Methods
new(organizer)
click to toggle source
# File lib/porch/step_chain.rb, line 5 def initialize(organizer) @organizer = organizer @steps = [] end
Public Instance Methods
add(step=nil, &block)
click to toggle source
# File lib/porch/step_chain.rb, line 10 def add(step=nil, &block) step = block if block_given? steps << ExecutableStepDecorator.new(step, organizer) end
execute(context)
click to toggle source
# File lib/porch/step_chain.rb, line 24 def execute(context) ctx = Context.new context steps.map do |step| ctx = step.execute ctx unless ctx.stop_processing? end.last || ctx end
insert(index, step=nil, &block)
click to toggle source
# File lib/porch/step_chain.rb, line 15 def insert(index, step=nil, &block) step = block if block_given? steps.insert index, ExecutableStepDecorator.new(step, organizer) end
remove(step)
click to toggle source
# File lib/porch/step_chain.rb, line 20 def remove(step) @steps.delete_if { |decorated_step| decorated_step.step == step } end