Module: ConvenientService::Support::DependencyContainer::Import Private

Includes:
Concern
Defined in:
lib/convenient_service/support/dependency_container/import.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Class Method Summary collapse

Methods included from Concern

included

Class Method Details

.import(slug, from:, as: Support::NOT_PASSED, scope: Constants::DEFAULT_SCOPE, prepend: Constants::DEFAULT_PREPEND) ⇒ ConvenientService::Support::DependencyContainer::Entities::Method

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • slug (String, Symbol)
  • as (String, Symbol, nil) (defaults to: Support::NOT_PASSED)
  • from (Module)
  • scope (:instance, :class) (defaults to: Constants::DEFAULT_SCOPE)
  • prepend (Boolean) (defaults to: Constants::DEFAULT_PREPEND)

Returns:

Since:

  • 1.0.0



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/convenient_service/support/dependency_container/import.rb', line 23

def import(slug, from:, as: Support::NOT_PASSED, scope: Constants::DEFAULT_SCOPE, prepend: Constants::DEFAULT_PREPEND)
  Commands::AssertValidScope.call(scope: scope)

  Commands::AssertValidContainer.call(container: from)

  Commands::AssertValidMethod.call(slug: slug, scope: scope, container: from)

  method = from.exported_methods.find_by(slug: slug, scope: scope)

  method = method.copy(overrides: {kwargs: {alias_slug: as}}) unless Support::NOT_PASSED[as]

  Commands::ImportMethod.call(importing_module: self, exported_method: method, prepend: prepend)
end