Class: Needle::Models::Prototype

Inherits:
Object
  • Object
show all
Defined in:
lib/needle/models/prototype.rb

Overview

The definition of the “prototype” lifecycle service model. This will result in immediate instantiation of the requested service, with a new instance being returned every time #instance is invoked.

Instance Method Summary collapse

Constructor Details

#initialize(container, opts = {}, &callback) ⇒ Prototype

Create a new instance of the Prototype service model.



26
27
28
29
# File 'lib/needle/models/prototype.rb', line 26

def initialize( container, opts={}, &callback )
  @container = container
  @callback = callback
end

Instance Method Details

#instanceObject

Invoke the callback that was given when the service model was instantiated, passing the service model’s container reference.



33
34
35
# File 'lib/needle/models/prototype.rb', line 33

def instance
  @callback.call( @container )
end