3 class RefError < RuntimeError; end
5 def self.create_weakref(obj)
6 Ruby.primitive :make_weak_ref
7 raise PrimitiveFailure, "unable to make weak reference"
10 def initialize(object)
11 @wr = self.class.create_weakref(object)
15 "#<WeakRef:0x#{object_id.to_s(16)} object=#{@wr.at(0).inspect}>"
24 raise RefError, "Object has been collected as garbage" unless obj