class Payload::MutableContainer
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.
Public Class Methods
Used internally by {RailsLoader} to parse dependency definition files.
@api private
# File lib/payload/mutable_container.rb, line 12 def initialize(container) @container = container @exported_names = [] end
Public Instance Methods
Used internally by {RailsLoader} to return the configured container.
@api private @return Container
the fully-configured, immutable container.
# File lib/payload/mutable_container.rb, line 31 def build @container end
Exports dependencies so that they are available in other containers.
@param names [Array<Symbol>] dependencies to export.
# File lib/payload/mutable_container.rb, line 38 def export(*names) @exported_names += names end
Returns dependencies specified by previous {#export} invocations.
Used internally by {RailsLoader}.
@api private
# File lib/payload/mutable_container.rb, line 47 def exports @container.export(*@exported_names) end
Delegates to {Container} and uses the returned result as the new container. @!method decorate @!method factory @!method service
# File lib/payload/mutable_container.rb, line 22 def method_missing(*args, &block) @container = @container.send(*args, &block) self end
Private Instance Methods
# File lib/payload/mutable_container.rb, line 53 def respond_to_missing?(*args) @container.respond_to?(*args) end