Module: Injectable
- Defined in:
- lib/injectable.rb,
lib/injectable/macros.rb,
lib/injectable/version.rb,
lib/injectable/registry.rb,
lib/injectable/container.rb,
lib/injectable/inflector.rb,
lib/injectable/registerable.rb
Overview
Objects that include Injectable can have their dependencies satisfied by the container, and removes some basic boilerplate code of creating basic constructors that set instance variables on the class. Constructor injection is the only available option here.
Defined Under Namespace
Modules: Inflector, Macros, Registerable, Registry Classes: Container
Constant Summary collapse
- VERSION =
"0.0.4"
Class Method Summary collapse
-
.configure ⇒ Injectable::Registry
Configure the global injectable registry.
-
.included(klass) ⇒ Object
Including the Injectable module will extend the class with the necessary macros.
Class Method Details
.configure ⇒ Injectable::Registry
Configure the global injectable registry. Simply just yields to the registry itself. If no block is provided returns the registry.
28 29 30 |
# File 'lib/injectable.rb', line 28 def configure block_given? ? yield(Registry) : Registry end |
.included(klass) ⇒ Object
Including the Injectable module will extend the class with the necessary macros.
43 44 45 46 47 48 49 |
# File 'lib/injectable.rb', line 43 def included(klass) Registry.register_implementation( Inflector.underscore(klass.name).to_sym, klass ) klass.extend(Macros) end |