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

Includes:
Concern
Included in:
Common::Plugins::HasInternals::Commands::CreateInternalsClass, RSpec::Helpers::Classes::StubService::Entities::StubbedService, RSpec::Matchers::Classes::Export, RSpec::Matchers::Classes::Results::Base::Entities::Printers::Error::Commands::GenerateGotJsendAttributesPart, RSpec::Matchers::Classes::Results::Base::Entities::Printers::Failure::Commands::GenerateGotJsendAttributesPart, RSpec::Matchers::Classes::Results::Base::Entities::Printers::Success::Commands::GenerateGotJsendAttributesPart, RSpec::Matchers::Classes::Results::Base::Entities::Validator::Commands::ValidateResultType, ConvenientService::Service::Plugins::CanHaveSteps::Commands::CreateStepClass, ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::RaisesOnNotResultReturnValue::Middleware, ConvenientService::Service::Plugins::HasJSendResult::Commands::CreateResultClass, ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Commands::CreateCodeClass, ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Commands::CreateDataClass, ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Commands::CreateMessageClass, ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Commands::CreateStatusClass, ConvenientService::Service::Plugins::RaisesOnNotResultReturnValue::Middleware
Defined in:
lib/convenient_service/support/dependency_container/import.rb

Class Method Summary collapse

Class Method Details

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

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:



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/convenient_service/support/dependency_container/import.rb', line 18

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}}) if as != Support::NOT_PASSED

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