Class: Carb::Inject::Injector
- Inherits:
-
Object
- Object
- Carb::Inject::Injector
- Defined in:
- lib/carb/inject/injector.rb
Overview
Creates an injector with the specified container
Instance Method Summary collapse
-
#[](*dependencies, **aliased) ⇒ DependencyList
Module which can be included and will take care of automatically injecting not-supplied dependency.
-
#initialize(container = nil, auto_inject = false) ⇒ Injector
constructor
Initialize an injector that can be attached to a constant with the given container.
Constructor Details
#initialize(container = nil, auto_inject = false) ⇒ Injector
Initialize an injector that can be attached to a constant with the given container
24 25 26 27 |
# File 'lib/carb/inject/injector.rb', line 24 def initialize(container = nil, auto_inject = false) @container = container || ::Carb::Container::ErrorContainer.new @auto_inject = auto_inject end |
Instance Method Details
#[](*dependencies, **aliased) ⇒ DependencyList
Returns module which can be included and will take care of automatically injecting not-supplied dependency.
43 44 45 46 47 48 49 |
# File 'lib/carb/inject/injector.rb', line 43 def [](*dependencies, **aliased) deps, lambdas = merge_dependencies(dependencies, aliased) wrapper = container wrapper = build_delegate(container, lambdas) unless lambdas.empty? Carb::Inject::DependencyList.new(wrapper, auto_inject, **deps) end |