Sha256: 057dafebfe3f159ba9f8aa120ac9375215e3f4727f60504031e0c5fc500ab219

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasJSendResult
        module Entities
          class Result
            module Plugins
              module HasStubbedResultInvocationsCounter
                class Middleware < MethodChainMiddleware
                  intended_for :initialize, entity: :result

                  ##
                  # @param args [Array<Object>]
                  # @param kwargs [Hash{Symbol => Object}]
                  # @param block [Proc, nil]
                  # @return [void]
                  #
                  # @internal
                  #   NOTE: It is okish to assign to next method arguments here.
                  #   Since splat for `args` and double splat for `kwargs` always create new arrays and hashes respectively.
                  #   - https://github.com/ruby/spec/blob/c7ed8478a031d0df346d222495f4b4bbb298523b/language/keyword_arguments_spec.rb#L100
                  #
                  def next(*args, **kwargs, &block)
                    kwargs[:stubbed_result_invocations_counter] = Support::ThreadSafeCounter.new if kwargs[:stubbed_result]

                    chain.next(*args, **kwargs, &block)
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.16.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_stubbed_result_invocations_counter/middleware.rb