Class: Ref::StrongReference

Inherits:
Reference show all
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

#referenced_object_id

Instance Method Summary collapse

Methods inherited from Reference

#inspect

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

#objectObject

Get the referenced object.



13
14
15
# File 'lib/ref/strong_reference.rb', line 13

def object
  @obj
end