class Ref::Reference
This class serves as a generic reference mechanism to other objects. The actual reference can be either a WeakReference, SoftReference, or StrongReference.
Attributes
referenced_object_id[R]
The object id of the object being referenced.
Public Class Methods
new(obj)
click to toggle source
Create a new reference to an object.
# File lib/ref/reference.rb, line 9 def initialize(obj) raise NotImplementedError.new("cannot instantiate a generic reference") end
Public Instance Methods
inspect()
click to toggle source
# File lib/ref/reference.rb, line 19 def inspect obj = object "<##{self.class.name}: #{obj ? obj.inspect : "##{referenced_object_id} (not accessible)"}>" end
object()
click to toggle source
Get the referenced object. This could be nil if the reference is a WeakReference or a SoftReference and the object has been reclaimed by the garbage collector.
# File lib/ref/reference.rb, line 15 def object raise NotImplementedError end