Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit 2c2e695

Browse files
author
Brian Durand
committed
Support for BasicObject in pure ruby weak reference implementation.
1 parent d72a5b7 commit 2c2e695

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.3
1+
1.0.4

lib/ref/weak_reference/pure_ruby.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def remove_backreference(obj) #:nodoc:
5454

5555
def supports_backreference?(obj)
5656
obj.respond_to?(:instance_variable_get) && obj.respond_to?(:instance_variable_defined?)
57+
rescue NoMethodError
58+
false
5759
end
5860
end
5961

test/weak_reference_test.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ def test_inspect
4444
assert ref.inspect
4545
end
4646

47-
class TestBasicObject < Object
48-
undef_method(:instance_variable_defined?)
49-
undef_method(:instance_variable_get)
50-
end
51-
52-
def test_basic_object_does_not_throw_exception
53-
obj = TestBasicObject.new
54-
Ref::WeakReference.new(obj)
47+
if defined?(BasicObject)
48+
def test_basic_object_does_not_throw_exception
49+
obj = BasicObject.new
50+
ref = Ref::WeakReference.new(obj)
51+
assert_nil ref.object
52+
end
5553
end
5654
end

0 commit comments

Comments
 (0)