Class: Hypo::Instance
- Inherits:
-
Object
- Object
- Hypo::Instance
- Includes:
- LifetimeFriendly, ScopeFriendly
- Defined in:
- lib/hypo/instance.rb
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(object, container, name) ⇒ Instance
constructor
A new instance of Instance.
- #instance(attrs = nil) ⇒ Object
Methods included from LifetimeFriendly
Methods included from ScopeFriendly
Constructor Details
#initialize(object, container, name) ⇒ Instance
Returns a new instance of Instance.
11 12 13 14 15 16 17 18 |
# File 'lib/hypo/instance.rb', line 11 def initialize(object, container, name) raise ContainerError, 'Registered object should have a name' if name.nil? @object = object @container = container @lifetime = container.lifetimes[:transient] @name = name end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
9 10 11 |
# File 'lib/hypo/instance.rb', line 9 def container @container end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/hypo/instance.rb', line 9 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
9 10 11 |
# File 'lib/hypo/instance.rb', line 9 def object @object end |
Instance Method Details
#instance(attrs = nil) ⇒ Object
20 21 22 |
# File 'lib/hypo/instance.rb', line 20 def instance(attrs = nil) @lifetime.instance(self) end |