diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-24 03:35:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-24 03:35:29 +0000 |
commit | 3c45a7899e239e7ece3c778d9f71e3be85fdfbed (patch) | |
tree | 6fef657de1a1751f08f92877a6d3fb469835c0c7 /lib | |
parent | dc62793a910097b2bb6a48ce5b6669c3ddb934ed (diff) | |
download | ruby-3c45a7899e239e7ece3c778d9f71e3be85fdfbed.tar.gz |
Delegate to `eql?` [Fix GH-1564]
* lib/delegate.rb (eql?): Delegate to `eql?` of the inner object.
based on the patch by giginet <giginet.net@gmail.com>.
[ruby-core:76950] [Bug #12684]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/delegate.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb index fa70848134..c5a94a5d31 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -40,7 +40,7 @@ class Delegator < BasicObject kernel = ::Kernel.dup kernel.class_eval do alias __raise__ raise - [:to_s, :inspect, :=~, :!~, :===, :<=>, :eql?, :hash].each do |m| + [:to_s, :inspect, :=~, :!~, :===, :<=>, :hash].each do |m| undef_method m end private_instance_methods.each do |m| @@ -146,6 +146,14 @@ class Delegator < BasicObject end # + # Returns true if two objects are considered of equal value. + # + def eql?(obj) + return true if obj.equal?(self) + obj.eql?(__getobj__) + end + + # # Delegates ! to the \_\_getobj\_\_ # def ! |