Class: Object

Inherits:
BasicObject
Defined in:
lib/needle/extras/attr-inject.rb

Instance Method Summary collapse

Instance Method Details

#inject_attributes(container) ⇒ Object

Injects all injectable attributes of the instance’s class with the corresponding services from the given container. Each attribute is injected into an identically named instance variable of the object, from an identically named service in the container.

This returns the object itself.



32
33
34
35
36
37
# File 'lib/needle/extras/attr-inject.rb', line 32

def inject_attributes( container )
  self.class.injectable_attributes.each do |attribute|
    instance_variable_set "@#{attribute}", container.get( attribute )
  end
  self
end