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

Class Method Details

.register(name, options = {}, &initializer) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
# File 'lib/deject.rb', line 7

def register(name, options={}, &initializer)
  raise ArgumentError, "#{name} has been registered multiple times" if options[: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

Returns:

  • (Boolean)


17
18
19
# File 'lib/deject.rb', line 17

def registered?(name)
  @registered.has_key? name.intern
end

.resetObject



21
22
23
# File 'lib/deject.rb', line 21

def reset
  @registered = {}
end