[前][次][番号順一覧][スレッド一覧]

ruby-changes:16334

From: marcandre <ko1@a...>
Date: Sun, 13 Jun 2010 04:25:21 +0900 (JST)
Subject: [ruby-changes:16334] Ruby:r28309 (trunk): * lib/delegate.rb: Delegate !=, eql? and hash

marcandre	2010-06-13 04:25:03 +0900 (Sun, 13 Jun 2010)

  New Revision: 28309

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28309

  Log:
    * lib/delegate.rb: Delegate !=, eql? and hash [ruby-core:26139]

  Modified files:
    trunk/ChangeLog
    trunk/lib/delegate.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28308)
+++ ChangeLog	(revision 28309)
@@ -1,3 +1,7 @@
+Sun Jun 13 04:24:18 2010  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* lib/delegate.rb: Delegate !=, eql? and hash [ruby-core:26139]
+
 Sun Jun 13 02:12:46 2010  NARUSE, Yui  <naruse@r...>
 
 	* enc/trans/utf8_mac.trans (buf_apply): fix for patterns
Index: lib/delegate.rb
===================================================================
--- lib/delegate.rb	(revision 28308)
+++ lib/delegate.rb	(revision 28309)
@@ -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 @@
   # 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 @@
   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.
   #

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]