module MinDI::Injectable::Injected

Internally used to extend service objects so that they can delegate sevice requests to their container.

This module can be included explicitly in the class of the service objects. For most purposes there is no reason to do so. However, if an object is dumped and re-loaded with YAML, it will lose track of modules that it has been extended with. By including the module in the class, the loaded object will have the right ancestors. (Marshal does not have this limitation.)

An object can be injected with at most one Injectable object at a time.

The implementation of Injected is essentially extend-ing with a module that has a method_missing.

Public Instance Methods

method_missing(*args, &block) click to toggle source

Delegates to the Injectable object any method which it must handle. If the Injectable object does not handle the method, or if there is no Injectable object assigned to self, then self’s own method_missing is called.

Calls superclass method
    # File lib/mindi.rb
294 def method_missing(*args, &block)
295   @__injectable__object__ || super
296   @__injectable__object__.send(*args, &block)
297 rescue NoInjectedMethodError
298   super
299 end