Sha256: 83a502f166fd7c09b5f3c56a1b0b5ec2e6cee223c8da604aebf234676eb1b2f9

Contents?: true

Size: 1.94 KB

Versions: 14

Compression:

Stored size: 1.94 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Core
    module Entities
      class Config
        module Entities
          class MethodMiddlewares
            module Entities
              ##
              # @internal
              #   NOTE: Do NOT pollute the interface of this class until really needed.
              #
              class Chain
                ##
                # @param stack [#call<Hash>]
                # @param env [Hash]
                # @return [void]
                #
                def initialize(stack:, env: {})
                  @stack = stack
                  @env = env
                end

                ##
                # @param args [Array]
                # @param kwargs [Hash]
                # @param block [Proc]
                # @return [Object] Can be any type.
                #
                # @internal
                #   TODO: Enforce to always pass args, kwargs, block.
                #
                def next(*args, **kwargs, &block)
                  stack.call(env.merge(args: args, kwargs: kwargs, block: block))
                end

                ##
                # @param other [ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::Chain, Object]
                # @return [Boolean]
                #
                def ==(other)
                  return unless other.instance_of?(self.class)

                  return false if stack != other.stack
                  return false if env != other.env

                  true
                end

                protected

                ##
                # @!attribute [r] stack
                #   @return [#call<Hash>]
                #
                attr_reader :stack

                ##
                # @!attribute [r] env
                #   @return [Hash]
                #
                attr_reader :env
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
convenient_service-0.11.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.10.1 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.10.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.9.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.8.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.7.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.6.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.5.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.4.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.3.1 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.3.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.2.1 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.2.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb
convenient_service-0.1.0 lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb