Class: Needle::Lifecycle::Initialize
- Inherits:
-
Pipeline::Element
- Object
- Pipeline::Element
- Needle::Lifecycle::Initialize
- Defined in:
- lib/needle/lifecycle/initialize.rb
Overview
The instantiation pipeline element that implements calling a separate initialization method on the instantiated service. This should always be placed in the pipeline as close to the service implementation as possible (hence, the low default priority).
Instance Attribute Summary
Attributes inherited from Pipeline::Element
#name, #options, #priority, #service_point, #succ
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Invokes the next element of the chain.
-
#initialize_element ⇒ Object
Initialize the element.
Methods inherited from Pipeline::Element
#<=>, #initialize, #reset!, set_default_priority
Constructor Details
This class inherits a constructor from Needle::Pipeline::Element
Instance Method Details
#call(*args) ⇒ Object
Invokes the next element of the chain. If the result responds to the requested initialization method, that method is invoked on the result, and the result is returned.
40 41 42 43 44 |
# File 'lib/needle/lifecycle/initialize.rb', line 40 def call( *args ) service = succ.call( *args ) service.send @init_method if service.respond_to?( @init_method ) service end |
#initialize_element ⇒ Object
Initialize the element. Looks at the options hash to determine the name of the initialization method to call, defaulting to :initialize_service
.
33 34 35 |
# File 'lib/needle/lifecycle/initialize.rb', line 33 def initialize_element @init_method = [:init_method] || :initialize_service end |