Class: Payload::MutableContainer
- Inherits:
-
Object
- Object
- Payload::MutableContainer
- Defined in:
- lib/payload/mutable_container.rb
Overview
Mutable builder for defining dependencies.
Allows defining dependencies without fear of breaking the chain while still encapsulating mutation in one location.
Decorates a Container and delegates definition calls.
Instance Method Summary collapse
-
#build ⇒ Object
private
Used internally by RailsLoader to return the configured container.
-
#decorate ⇒ Object
Delegates to Container and uses the returned result as the new container.
-
#export(*names) ⇒ Object
Exports dependencies so that they are available in other containers.
-
#exports ⇒ Object
private
Returns dependencies specified by previous #export invocations.
-
#factory ⇒ Object
Delegates to Container and uses the returned result as the new container.
-
#initialize(container) ⇒ MutableContainer
constructor
private
Used internally by RailsLoader to parse dependency definition files.
-
#method_missing(*args, &block) ⇒ Object
Delegates to Container and uses the returned result as the new container.
-
#service ⇒ Object
Delegates to Container and uses the returned result as the new container.
Constructor Details
#initialize(container) ⇒ MutableContainer
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.
Used internally by RailsLoader to parse dependency definition files.
12 13 14 15 |
# File 'lib/payload/mutable_container.rb', line 12 def initialize(container) @container = container @exported_names = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
Delegates to Container and uses the returned result as the new container.
22 23 24 25 |
# File 'lib/payload/mutable_container.rb', line 22 def method_missing(*args, &block) @container = @container.send(*args, &block) self end |
Instance Method Details
#build ⇒ Object
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.
Used internally by RailsLoader to return the configured container.
31 32 33 |
# File 'lib/payload/mutable_container.rb', line 31 def build @container end |
#decorate ⇒ Object
Delegates to Container and uses the returned result as the new container.
22 23 24 25 |
# File 'lib/payload/mutable_container.rb', line 22 def method_missing(*args, &block) @container = @container.send(*args, &block) self end |
#export(*names) ⇒ Object
Exports dependencies so that they are available in other containers.
38 39 40 |
# File 'lib/payload/mutable_container.rb', line 38 def export(*names) @exported_names += names end |
#exports ⇒ Object
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.
Returns dependencies specified by previous #export invocations.
Used internally by RailsLoader.
47 48 49 |
# File 'lib/payload/mutable_container.rb', line 47 def exports @container.export(*@exported_names) end |
#factory ⇒ Object
Delegates to Container and uses the returned result as the new container.
22 23 24 25 |
# File 'lib/payload/mutable_container.rb', line 22 def method_missing(*args, &block) @container = @container.send(*args, &block) self end |
#service ⇒ Object
Delegates to Container and uses the returned result as the new container.
22 23 24 25 |
# File 'lib/payload/mutable_container.rb', line 22 def method_missing(*args, &block) @container = @container.send(*args, &block) self end |