class Porch::ExecutableStepDecorator

Attributes

decorated_step[R]

Public Class Methods

new(step, organizer) click to toggle source
# File lib/porch/executable_step_decorator.rb, line 13
def initialize(step, organizer)
  @decorated_step = decorate step, organizer
end
registered_decorators() click to toggle source
# File lib/porch/executable_step_decorator.rb, line 26
def self.registered_decorators
  [ClassStepDecorator, MethodStepDecorator, ProcStepDecorator].freeze
end

Public Instance Methods

execute(context) click to toggle source
# File lib/porch/executable_step_decorator.rb, line 17
def execute(context)
  begin
    decorated_step.execute context
  rescue Porch::ContextStoppedError => e
    # this exception is just used for flow control
    e.context
  end
end
step() click to toggle source
# File lib/porch/executable_step_decorator.rb, line 9
def step
  decorated_step.step
end

Private Instance Methods

decorate(step, organizer) click to toggle source
# File lib/porch/executable_step_decorator.rb, line 32
def decorate(step, organizer)
  decorator = self.class.registered_decorators.find { |d| d.decorates?(step) }
  raise InvalidStepTypeError.new(step) if decorator.nil?
  decorator.new(step, organizer)
end