diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/delegate.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb index dead782bbb..2c1db88a75 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -117,7 +117,7 @@ class Delegator < BasicObject kernel = ::Kernel.dup kernel.class_eval do - [:to_s,:inspect,:=~,:!~,:===,:<=>].each do |m| + [:to_s,:inspect,:=~,:!~,:===,:<=>,:eql?,:hash].each do |m| undef_method m end end @@ -187,7 +187,7 @@ class Delegator < BasicObject # Note: no need to specialize private_methods, since they are not forwarded # - # Returns true if two objects are considered same. + # Returns true if two objects are considered of equal value. # def ==(obj) return true if obj.equal?(self) @@ -195,6 +195,18 @@ class Delegator < BasicObject end # + # Returns true if two objects are not considered of equal value. + # + def !=(obj) + return false if obj.equal?(self) + __getobj__ != obj + end + + def ! + !__getobj__ + end + + # # This method must be overridden by subclasses and should return the object # method calls are being delegated to. # |