Skip to content

Commit

Permalink
Only use UnboundMethod#bind_call if it is available
Browse files Browse the repository at this point in the history
This allows tests to pass on Ruby 2.4-2.6.

Fixes #19
  • Loading branch information
jeremyevans committed Mar 4, 2021
1 parent d47dae2 commit 67ca99c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/uri/rfc2396_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,14 @@ def unescape(str, escaped = @regexp[:ESCAPED])
end

@@to_s = Kernel.instance_method(:to_s)
def inspect
@@to_s.bind_call(self)
if @@to_s.respond_to?(:bind_call)
def inspect
@@to_s.bind_call(self)
end
else
def inspect
@@to_s.bind(self).call
end
end

private
Expand Down
10 changes: 8 additions & 2 deletions lib/uri/rfc3986_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ def join(*uris) # :nodoc:
end

@@to_s = Kernel.instance_method(:to_s)
def inspect
@@to_s.bind_call(self)
if @@to_s.respond_to?(:bind_call)
def inspect
@@to_s.bind_call(self)
end
else
def inspect
@@to_s.bind(self).call
end
end

private
Expand Down

0 comments on commit 67ca99c

Please sign in to comment.