Class: Dee::Container::SingletonFactory

Inherits:
Factory
  • Object
show all
Defined in:
lib/dee/container.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ SingletonFactory

Returns a new instance of SingletonFactory.



14
15
16
17
# File 'lib/dee/container.rb', line 14

def initialize(&block)
  @block = block
  @value = nil
end

Instance Method Details

#createObject



19
20
21
22
# File 'lib/dee/container.rb', line 19

def create
  @value = @block.call unless @value
  @value
end