Module: Untangle

Defined in:
lib/untangle.rb,
lib/untangle/version.rb,
lib/untangle/injector.rb

Defined Under Namespace

Classes: Injector

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inject(method) ⇒ Object


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

def self.inject(method)
  injector.inject(method)
end

.injectorObject


5
6
7
# File 'lib/untangle.rb', line 5

def self.injector
  @injector ||= Injector.new
end

.lookup(name) ⇒ Object


13
14
15
# File 'lib/untangle.rb', line 13

def self.lookup(name)
  injector.lookup(name)
end

.register(name, dependency) ⇒ Object


9
10
11
# File 'lib/untangle.rb', line 9

def self.register(name, dependency)
  injector.register(name, dependency)
end

Instance Method Details

#dependency(name, *args, &block) ⇒ Object


25
26
27
28
29
30
31
32
33
# File 'lib/untangle.rb', line 25

def dependency(name, *args, &block)
  custom_injector = injector
  custom_injector.register name, *args, &block

  define_method name do
    custom_injector.lookup(name)
  end
  private name
end

#injectorObject


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

def injector
  @injector ||= Injector.new(Untangle.injector)
end