Sha256: 016336654d0b163c9421c2e5480960a110d86681c115c8d3aa43ac89b07703a9

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasJSendResult
        module Entities
          class Result
            module Plugins
              module CanHaveCheckedStatus
                class Middleware < MethodChainMiddleware
                  intended_for [
                    :success?,
                    :failure?,
                    :error?,
                    :not_success?,
                    :not_failure?,
                    :not_error?
                  ],
                    entity: :result

                  ##
                  # @param args [Array<Object>]
                  # @param kwargs [Hash{Symbol => Object}]
                  # @param block [Proc, nil]
                  # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
                  #
                  def next(*args, **kwargs, &block)
                    mark_status_as_checked = kwargs.fetch(:mark_status_as_checked) { true }

                    entity.internals.cache[:has_checked_status] = true if mark_status_as_checked

                    chain.next(*args, **Utils::Hash.except(kwargs, [:mark_status_as_checked]), &block)
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
convenient_service-0.17.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb
convenient_service-0.16.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb