Sha256: 65f5665b15e7a3b70958cce21e51e00883f8a29350102b6babd8f3e60b3d361c

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveStubbedResults
        module Concern
          include Support::Concern

          included do |service_class|
            service_class.extend ClassMethods

            ##
            # IMPORTANT:
            #   - Initializes `stubbed_results` during the `include Concern` process.
            #   - Tries to enforce thread-safety in such a way.
            #   - https://github.com/ruby/spec/blob/master/core/module/include_spec.rb
            #   - https://github.com/ruby/ruby/blob/master/class.c
            #
            service_class.stubbed_results
          end

          class_methods do
            ##
            # @return [ConvenientService::Support::Cache]
            #
            # @internal
            #   NOTE: `self` is a service class in the current context. For example:
            #
            #   before do
            #     stub_service(ConvenientService::Examples::Standard::Gemfile::Services::RunShellCommand)
            #       .with_arguments(command: node_available_command)
            #       .to return_result(node_available_status)
            #   end
            #
            #   # Then `self` is `ConvenientService::Examples::Standard::Gemfile::Services::RunShellCommand`.
            #
            def stubbed_results
              Commands::FetchServiceStubbedResultsCache.call(service: self)
            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/concern.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb
convenient_service-0.16.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb