Sha256: 56516c7eff2a4bae2e2d4bc8e94784cb70dda75a95891d44e3b9aa83ce82ef07

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

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

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

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

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

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

          private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb