Class: Jerry
- Inherits:
-
Object
- Object
- Jerry
- Defined in:
- lib/jerry.rb,
lib/jerry/config.rb,
lib/jerry/version.rb
Overview
Inversion of Control container.
This class is in charge of bootstrapping your application. This is done by defining configs.
Defined Under Namespace
Classes: ComponentError, Config, RigError
Constant Summary collapse
- VERSION =
'1.0.1'
Instance Method Summary collapse
-
#<<(config) ⇒ Object
Load a config.
-
#initialize(*configs) ⇒ Jerry
constructor
A new instance of Jerry.
-
#knows?(component) ⇒ Boolean
Checks if a component exists.
-
#rig(component) ⇒ Object
Rigs a component.
Constructor Details
#initialize(*configs) ⇒ Jerry
Returns a new instance of Jerry.
20 21 22 23 24 |
# File 'lib/jerry.rb', line 20 def initialize(*configs) @index = {} configs.each { |config| self << config } end |
Instance Method Details
#<<(config) ⇒ Object
Load a config
30 31 32 33 34 |
# File 'lib/jerry.rb', line 30 def <<(config) components = config.components components.each { |component| @index[component] = config } config.jerry = self end |
#knows?(component) ⇒ Boolean
Checks if a component exists
50 51 52 |
# File 'lib/jerry.rb', line 50 def knows?(component) @index.has_key? component end |
#rig(component) ⇒ Object
Rigs a component
41 42 43 44 45 |
# File 'lib/jerry.rb', line 41 def rig(component) raise RigError, "could not find component #{component}" unless knows? component @index[component].public_send component end |