From 10ad81eb2d4bf44b5d5350e3ea28e6248f550128 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 4 Mar 2021 15:19:25 -0800 Subject: [ruby/uri] Only use UnboundMethod#bind_call if it is available This allows tests to pass on Ruby 2.4-2.6. Fixes #19 https://github.com/ruby/uri/commit/67ca99ca87 --- lib/uri/rfc2396_parser.rb | 10 ++++++++-- lib/uri/rfc3986_parser.rb | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'lib/uri') diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index 1c9ce177bc..76a8f99fd4 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -322,8 +322,14 @@ module URI 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 diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index 49a594c17d..3e07de4805 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -79,8 +79,14 @@ module URI 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 -- cgit v1.2.3