Class: Decouplio::Steps::Wrap

Inherits:
BaseStep
  • Object
show all
Defined in:
lib/decouplio/steps/wrap.rb

Instance Attribute Summary

Attributes inherited from BaseStep

#name

Instance Method Summary collapse

Constructor Details

#initialize(name:, klass:, method:, wrap_flow:, on_success_type:, on_failure_type:) ⇒ Wrap

Returns a new instance of Wrap.



10
11
12
13
14
15
16
17
18
# File 'lib/decouplio/steps/wrap.rb', line 10

def initialize(name:, klass:, method:, wrap_flow:, on_success_type:, on_failure_type:)
  super()
  @name = name
  @klass = klass
  @method = method
  @wrap_flow = wrap_flow
  @on_success_type = on_success_type
  @on_failure_type = on_failure_type
end

Instance Method Details

#process(instance:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/decouplio/steps/wrap.rb', line 20

def process(instance:)
  instance.append_railway_flow(@name)
  if specific_wrap?
    @klass.public_send(@method) do
      Decouplio::Processor.call(instance: instance, **@wrap_flow)
    end
  else
    Decouplio::Processor.call(instance: instance, **@wrap_flow)
  end

  resolve(instance: instance)
end