Class: Liveness::Container
- Inherits:
-
Object
- Object
- Liveness::Container
- Defined in:
- lib/liveness/container.rb
Overview
The dependency provider container
Instance Method Summary collapse
-
#create(name, **options, &block) ⇒ Liveness::Dependency|NilClass
Create a dependency.
- #initialize ⇒ Liveness::Container constructor
-
#register(name, klass) ⇒ Object
Register new dependency type.
Constructor Details
#initialize ⇒ Liveness::Container
11 12 13 |
# File 'lib/liveness/container.rb', line 11 def initialize @dependencies = {} end |
Instance Method Details
#create(name, **options, &block) ⇒ Liveness::Dependency|NilClass
Create a dependency
33 34 35 36 37 38 39 |
# File 'lib/liveness/container.rb', line 33 def create(name, **, &block) klass = @dependencies[name.to_sym] return if klass.nil? [:name] ||= name klass.new(**, &block) end |
#register(name, klass) ⇒ Object
Register new dependency type
21 22 23 |
# File 'lib/liveness/container.rb', line 21 def register(name, klass) @dependencies[name.to_sym] = klass end |