Sha256: 37888ccd6e663273920b43d9d711d96882a3a52e3a25d8476bfd319b1d31007e

Contents?: true

Size: 607 Bytes

Versions: 5

Compression:

Stored size: 607 Bytes

Contents

class Wref::Implementations::Weakling
  def initialize(object)
    require "weakling"
    @weak_ref = ::Weakling::WeakRef.new(object)
  end

  def get
    begin
      @weak_ref.get
    rescue ::WeakRef::RefError, ::Java::JavaLang::NullPointerException
      return nil
    end
  end

  def get!
    begin
      @weak_ref.get
    rescue ::WeakRef::RefError, ::Java::JavaLang::NullPointerException
      raise Wref::Recycled
    end
  end

  def alive?
    begin
      @weak_ref.get
      return true
    rescue ::WeakRef::RefError, ::Java::JavaLang::NullPointerException
      return false
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wref-0.0.11 lib/wref/implementations/weakling.rb
wref-0.0.10 lib/wref/implementations/weakling.rb
wref-0.0.9 lib/wref/implementations/weakling.rb
wref-0.0.8 lib/wref/implementations/weakling.rb
wref-0.0.7 lib/wref/implementations/weakling.rb