Sha256: a186845168e543ce9666cb4b2e7d2fcd0327f515316d42fbafec92043fda930f

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveSteps
        module Entities
          class Step
            module Plugins
              module CanHaveParentResult
                class Middleware < MethodChainMiddleware
                  intended_for :result, entity: :step

                  ##
                  # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
                  # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
                  #
                  # @internal
                  #   IMPORTANT: `CanHaveParentResult` middleware MUST be placed after `HasResult` middleware.
                  #
                  #   NOTE: `result` at the moment of this middleware is still a `service_result` (or `method_result`). It is only later converted to `step_result` by `HasResult` middleware.
                  #   That is why `result` is used as `parent` here.
                  #
                  def next(...)
                    result = chain.next(...)

                    result.copy(overrides: {kwargs: {parent: result}})
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_parent_result/middleware.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_parent_result/middleware.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_parent_result/middleware.rb