Module: Deject
- Defined in:
- lib/deject.rb,
lib/deject/version.rb
Constant Summary collapse
- UninitializedDependency =
Class.new StandardError
- VERSION =
'0.2.3'
Class Method Summary collapse
- .register(name, options = {}, &initializer) ⇒ Object
- .registered(name) ⇒ Object
- .registered?(name) ⇒ Boolean
- .reset ⇒ Object
Class Method Details
.register(name, options = {}, &initializer) ⇒ Object
7 8 9 10 11 |
# File 'lib/deject.rb', line 7 def register(name, ={}, &initializer) raise ArgumentError, "#{name} has been registered multiple times" if [:safe] && registered?(name) raise ArgumentError, "#{name} has been registered with Deject without an initialization block" unless initializer @registered[name.intern] = initializer end |
.registered(name) ⇒ Object
13 14 15 |
# File 'lib/deject.rb', line 13 def registered(name) @registered[name.intern] end |
.registered?(name) ⇒ Boolean
17 18 19 |
# File 'lib/deject.rb', line 17 def registered?(name) @registered.has_key? name.intern end |
.reset ⇒ Object
21 22 23 |
# File 'lib/deject.rb', line 21 def reset @registered = {} end |