Sha256: adba17034b81b1ddd0df85a0b2d94fdf31e617d220a3e7c234d19f41c18d3ddc

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveStubbedResults
        module Commands
          class GetServiceStubbedResult < Support::Command
            ##
            # @!attribute [r] service
            #   @return [ConvenientService::Service]
            #
            attr_reader :service

            ##
            # @!attribute [r] arguments
            #   @return [ConvenientService::Support::Arguments]
            #
            attr_reader :arguments

            ##
            # @param service [ConvenientService::Service]
            # @param arguments [ConvenientService::Support::Arguments]
            # @return [void]
            #
            def initialize(service:, arguments:)
              @service = service
              @arguments = arguments
            end

            ##
            # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
            #
            def call
              cache.read(key)
            end

            private

            ##
            # @return [ConvenientService::Support::Cache]
            #
            def cache
              @cache ||= Commands::FetchServiceStubbedResultsCache.call(service: service)
            end

            ##
            # @return [ConvenientService::Support::Cache::Entities::Key]
            #
            def key
              @key ||= cache.keygen(*arguments.args, **arguments.kwargs, &arguments.block)
            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/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.16.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/can_have_stubbed_results/commands/get_service_stubbed_result.rb