Skip to content

Commit 67ca99c

Browse files
committed
Only use UnboundMethod#bind_call if it is available
This allows tests to pass on Ruby 2.4-2.6. Fixes #19
1 parent d47dae2 commit 67ca99c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/uri/rfc2396_parser.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,14 @@ def unescape(str, escaped = @regexp[:ESCAPED])
322322
end
323323

324324
@@to_s = Kernel.instance_method(:to_s)
325-
def inspect
326-
@@to_s.bind_call(self)
325+
if @@to_s.respond_to?(:bind_call)
326+
def inspect
327+
@@to_s.bind_call(self)
328+
end
329+
else
330+
def inspect
331+
@@to_s.bind(self).call
332+
end
327333
end
328334

329335
private

lib/uri/rfc3986_parser.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,14 @@ def join(*uris) # :nodoc:
7979
end
8080

8181
@@to_s = Kernel.instance_method(:to_s)
82-
def inspect
83-
@@to_s.bind_call(self)
82+
if @@to_s.respond_to?(:bind_call)
83+
def inspect
84+
@@to_s.bind_call(self)
85+
end
86+
else
87+
def inspect
88+
@@to_s.bind(self).call
89+
end
8490
end
8591

8692
private

0 commit comments

Comments
 (0)