lib/dirty_pipeline/transition.rb in dirty_pipeline-0.5.0 vs lib/dirty_pipeline/transition.rb in dirty_pipeline-0.6.0

- old
+ new

@@ -1,24 +1,24 @@ module DirtyPipeline class Transition def Abort() - throw :abort, true + throw :fail_operation, :abort end def Error(error) - throw :fail_with_error, error + throw :fail_operation, error end def Success(changes = nil) throw :success, changes.to_h end def self.finalize(*args, **kwargs) event, pipeline, *args = args instance = new(event, *args, **kwargs) - pipeline.railway.switch_to(:call) return unless instance.respond_to?(:finalize) + pipeline.railway.switch_to(:call) instance.finalize(pipeline.subject) end def self.undo(*args, **kwargs) event, pipeline, *args = args @@ -29,11 +29,13 @@ def self.call(*args, **kwargs) event, pipeline, *args = args instance = new(event, *args, **kwargs) pipeline.railway[:undo] << event if instance.respond_to?(:undo) - pipeline.railway[:finalize] << event if instance.respond_to?(:finalize) - pipeline.railway.switch_to(:finalize) if instance.respond_to?(:finalize) + if instance.respond_to?(:finalize) + pipeline.railway[:finalize] << event + pipeline.railway.switch_to(:finalize) + end new(event, *args, **kwargs).call(pipeline.subject) end attr_reader :event def initialize(event, *, **)