Sha256: 6307d5a5a30a53f662ee4ce9baa2a9fbb7f1b3bf4947697ffbca8c8722dac92c

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Support
    module DependencyContainer
      module Export
        include Support::Concern

        class_methods do
          ##
          # @param full_name [String, Symbol]
          # @param scope [:instance, :class]
          # @param body [Proc]
          # @return [ConvenientService::Support::DependencyContainer::Entities::Method]
          #
          # @internal
          #   NOTE: `export` does NOT accept `prepend` kwarg intentionally.
          #   It is done to follow "the Ruby way".
          #   You won't ever see a module in Ruby that contains methods for `include` and `prepend` at the same time.
          #   So why `export` should allow to do it?
          #
          def export(full_name, scope: Constants::DEFAULT_SCOPE, &body)
            Commands::AssertValidScope.call(scope: scope)

            Entities::Method.new(full_name: full_name, scope: scope, body: body).tap { |method| exported_methods << method }
          end

          ##
          # @return [ConvenientService::Support::DependencyContainer::Entities::MethodCollection]
          #
          def exported_methods
            @exported_methods ||= Entities::MethodCollection.new
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
convenient_service-0.8.0 lib/convenient_service/support/dependency_container/export.rb
convenient_service-0.7.0 lib/convenient_service/support/dependency_container/export.rb
convenient_service-0.6.0 lib/convenient_service/support/dependency_container/export.rb