Class: Ref::StrongReference
- Defined in:
- lib/ref/strong_reference.rb
Overview
This implementation of Reference holds a strong reference to an object. The referenced object will not be garbage collected as long as the strong reference exists.
Instance Attribute Summary
Attributes inherited from Reference
Instance Method Summary collapse
-
#initialize(obj) ⇒ StrongReference
constructor
Create a new strong reference to an object.
-
#object ⇒ Object
Get the referenced object.
Methods inherited from Reference
Constructor Details
#initialize(obj) ⇒ StrongReference
Create a new strong reference to an object.
7 8 9 10 |
# File 'lib/ref/strong_reference.rb', line 7 def initialize(obj) @obj = obj @referenced_object_id = obj.__id__ end |
Instance Method Details
#object ⇒ Object
Get the referenced object.
13 14 15 |
# File 'lib/ref/strong_reference.rb', line 13 def object @obj end |