Sha256: a5cb8e650d20c76136e35f10df69cc812d8bf491f087dca165726aabf1b5f480

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 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
            ::ConvenientService.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.19.1 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb
convenient_service-0.19.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb
convenient_service-0.18.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb
convenient_service-0.17.0 lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb