Class: DiFtw::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/diftw/factory.rb

Overview

A dependency that will be re-created every time it’s injected.

Instance Method Summary collapse

Constructor Details

#initialize(y) ⇒ Factory

A new dependency.

Parameters:

  • y (Proc)

    returns the dependency



11
12
13
14
# File 'lib/diftw/factory.rb', line 11

def initialize(y)
  @y = y
  @val = nil
end

Instance Method Details

#resolveObject

Return the value for the dependency by calling the registration Proc.



19
20
21
# File 'lib/diftw/factory.rb', line 19

def resolve
  @y.call
end