mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/delegate.rb: Delegate !=, eql? and hash [ruby-core:26139]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
78f5b54f1b
commit
0486db01fd
2 changed files with 18 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
Sun Jun 13 04:24:18 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/delegate.rb: Delegate !=, eql? and hash [ruby-core:26139]
|
||||
|
||||
Sun Jun 13 02:12:46 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* enc/trans/utf8_mac.trans (buf_apply): fix for patterns
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue