Class | WeakRef
In: | weakref.rb
Parent: | Delegator

### Methods

__getobj__ new weakref_alive?

### Classes and Modules

Class WeakRef::RefError

### Public Class methods

new(orig)

[Source]

    # File weakref.rb, line 43
      def initialize(orig)
        super
        @__id = orig.__id__
        ObjectSpace.define_finalizer orig, @@final
        ObjectSpace.define_finalizer self, @@final
        __old_status = Thread.critical
        begin
          Thread.critical = true
          @@id_map[@__id] = [] unless @@id_map[@__id]
        ensure
          Thread.critical = __old_status
        end
        @@id_map[@__id].push self.__id__
        @@id_rev_map[self.__id__] = @__id
      end

### Public Instance methods

__getobj__()

[Source]

    # File weakref.rb, line 59
      def __getobj__
        unless @@id_rev_map[self.__id__] == @__id
          raise RefError, "Illegal Reference - probably recycled", caller(2)
        end
        begin
          ObjectSpace._id2ref(@__id)
        rescue RangeError
          raise RefError, "Illegal Reference - probably recycled", caller(2)
        end
      end

weakref_alive?()

[Source]

    # File weakref.rb, line 70
      def weakref_alive?
        @@id_rev_map[self.__id__] == @__id
      end

[Validate]