Class: Decouplio::Steps::BaseResq
- Defined in:
- lib/decouplio/steps/base_resq.rb
Instance Attribute Summary
Attributes inherited from BaseStep
Instance Method Summary collapse
-
#initialize(handler_hash:, step_to_resq:, on_error_type:) ⇒ BaseResq
constructor
A new instance of BaseResq.
- #process(instance:) ⇒ Object
Constructor Details
#initialize(handler_hash:, step_to_resq:, on_error_type:) ⇒ BaseResq
Returns a new instance of BaseResq.
8 9 10 11 12 13 |
# File 'lib/decouplio/steps/base_resq.rb', line 8 def initialize(handler_hash:, step_to_resq:, on_error_type:) super() @handler_hash = handler_hash @step_to_resq = step_to_resq @on_error_type = on_error_type end |
Instance Method Details
#process(instance:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/decouplio/steps/base_resq.rb', line 15 def process(instance:) result = @step_to_resq.process(instance: instance) rescue *@handler_hash.keys => e handler_method = @handler_hash[e.class] raise e unless handler_method instance.append_railway_flow(handler_method) instance.public_send(handler_method, e, **instance.ctx) case @on_error_type when Decouplio::Const::Results::PASS, Decouplio::Const::Results::STEP_PASS instance.pass_action Decouplio::Const::Results::ERROR when Decouplio::Const::Results::FINISH_HIM instance.fail_action Decouplio::Const::Results::FINISH_HIM else instance.fail_action Decouplio::Const::Results::ERROR end else result end |