Sha256: 42fc98ede75af78ccc7e3e29e5357dc4a1da75fd0420dae53050a2cfe84a2d3e

Contents?: true

Size: 774 Bytes

Versions: 13

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Common
    module Plugins
      module CachesReturnValue
        class Middleware < Core::MethodChainMiddleware
          ##
          # @param args [Array]
          # @param kwargs [Hash]
          # @param block [Proc]
          # @return [Object] Can be any type.
          #
          def next(*args, **kwargs, &block)
            key = cache.keygen(:return_values, method, *args, **kwargs, &block)

            cache.fetch(key) { chain.next(*args, **kwargs, &block) }
          end

          private

          ##
          # @return [ConvenientService::Support::Cache]
          #
          def cache
            @cache ||= entity.internals.cache
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
convenient_service-0.11.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.10.1 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.10.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.9.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.8.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.7.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.6.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.5.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.4.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.3.1 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.3.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.2.1 lib/convenient_service/common/plugins/caches_return_value/middleware.rb
convenient_service-0.2.0 lib/convenient_service/common/plugins/caches_return_value/middleware.rb