Module: MinDI::Injectable::Injected
- Defined in:
- lib/mindi.rb
Overview
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
.
Instance Method Summary collapse
-
#method_missing(*args, &block) ⇒ Object
Delegates to the Injectable object any method which it must handle.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
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.
294 295 296 297 298 299 |
# File 'lib/mindi.rb', line 294 def method_missing(*args, &block) @__injectable__object__ || super @__injectable__object__.send(*args, &block) rescue NoInjectedMethodError super end |