Sha256: bc5132b69a1eeced6ffe6389454f12221ae03327ffc0367364acb401f6692d19

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Support
    module DependencyContainer
      module Commands
        class AssertValidMethod < Support::Command
          ##
          # @!attribute [r] slug
          #   @return [String, Symbol]
          #
          attr_reader :slug

          ##
          # @!attribute [r] scope
          #   @return [Symbol]
          #
          attr_reader :scope

          ##
          # @!attribute [r] container
          #   @return [Module]
          #
          attr_reader :container

          ##
          # @param slug [String, Symbol]
          # @param scope [Symbol]
          # @param container[Module]
          # @return [void]
          #
          def initialize(slug:, scope:, container:)
            @slug = slug
            @scope = scope
            @container = container
          end

          ##
          # @return [void]
          # @raise [ConvenientService::Support::DependencyContainer::Exceptions::NotExportedMethod]
          #
          def call
            raise Exceptions::NotExportedMethod.new(method_name: slug, method_scope: scope, mod: container) unless method
          end

          private

          ##
          # @return [ConvenientService::Support::DependencyContainer::Entities::Method, nil]
          #
          def method
            container.exported_methods.find_by(slug: slug, scope: scope)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.16.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb
convenient_service-0.15.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb
convenient_service-0.14.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb
convenient_service-0.13.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb