Sha256: 10d4826c79c9501860caa110f960df28c41c8bc3fb9f14ab44686fe004522fc7

Contents?: true

Size: 646 Bytes

Versions: 6

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasResultSteps
        class Middleware < Core::MethodChainMiddleware
          def next(...)
            return chain.next(...) if entity.steps.none?

            last_step.result.copy
          end

          private

          def last_step
            ##
            # TODO: Use `entity.steps.find { |step| step.result.tap { |result| entity.step(result) }.not_success? }` for callbacks.
            #
            @last_step ||= entity.steps.find(&:not_success?) || entity.steps.last
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
convenient_service-0.6.0 lib/convenient_service/service/plugins/has_result_steps/middleware.rb
convenient_service-0.5.0 lib/convenient_service/service/plugins/has_result_steps/middleware.rb
convenient_service-0.4.0 lib/convenient_service/service/plugins/has_result_steps/middleware.rb
convenient_service-0.3.1 lib/convenient_service/service/plugins/has_result_steps/middleware.rb
convenient_service-0.3.0 lib/convenient_service/service/plugins/has_result_steps/middleware.rb
convenient_service-0.2.1 lib/convenient_service/service/plugins/has_result_steps/middleware.rb