diff --git a/ChangeLog b/ChangeLog index 0370a0b47d..8e9a15f8e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Jun 13 04:24:18 2010 Marc-Andre Lafortune + + * lib/delegate.rb: Delegate !=, eql? and hash [ruby-core:26139] + Sun Jun 13 02:12:46 2010 NARUSE, Yui * enc/trans/utf8_mac.trans (buf_apply): fix for patterns 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,13 +187,25 @@ 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) self.__getobj__ == obj 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.