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

ruby-changes:21890

From: naruse <ko1@a...>
Date: Sun, 4 Dec 2011 12:05:15 +0900 (JST)
Subject: [ruby-changes:21890] naruse:r33939 (trunk): * lib/delegate.rb (Delegator#methods): Kernel#methods receives

naruse	2011-12-04 12:05:03 +0900 (Sun, 04 Dec 2011)

  New Revision: 33939

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

  Log:
    * lib/delegate.rb (Delegator#methods): Kernel#methods receives
      zero or one argument. [ruby-core:37118] [Bug #4882]

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/lib/delegate.rb
    trunk/test/test_delegate.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33938)
+++ ChangeLog	(revision 33939)
@@ -1,3 +1,8 @@
+Sun Dec  4 12:03:16 2011  NARUSE, Yui  <naruse@r...>
+
+	* lib/delegate.rb (Delegator#methods): Kernel#methods receives
+	  zero or one argument. [ruby-core:37118] [Bug #4882]
+
 Sun Dec  4 10:15:00 2011  Luis Lavena  <luislavena@g...>
 
 	* ext/zlib/zlib.c (rb_gzreader_initialize): use binary mode by default
Index: lib/delegate.rb
===================================================================
--- lib/delegate.rb	(revision 33938)
+++ lib/delegate.rb	(revision 33939)
@@ -92,8 +92,8 @@
   # Returns the methods available to this delegate object as the union
   # of this object's and \_\_getobj\_\_ methods.
   #
-  def methods
-    __getobj__.methods | super
+  def methods(all=true)
+    __getobj__.methods(all) | super
   end
 
   #
Index: class.c
===================================================================
--- class.c	(revision 33938)
+++ class.c	(revision 33939)
@@ -1111,11 +1111,13 @@
 
 /*
  *  call-seq:
- *     obj.methods    -> array
+ *     obj.methods(all=true)    -> array
  *
  *  Returns a list of the names of public and protected methods of
  *  <i>obj</i>. This will include all the methods accessible in
  *  <i>obj</i>'s ancestors.
+ *  If the <i>all</i> parameter is set to <code>false</code>, only those methods
+ *  in the receiver will be listed.
  *
  *     class Klass
  *       def klass_method()
Index: test/test_delegate.rb
===================================================================
--- test/test_delegate.rb	(revision 33938)
+++ test/test_delegate.rb	(revision 33939)
@@ -111,6 +111,13 @@
     assert_raise(NoMethodError, '[ruby-dev:40314]#3') {m.call}
   end
 
+  def test_methods
+    s = SimpleDelegator.new("foo")
+    assert_equal([], s.methods(false))
+    def s.bar; end
+    assert_equal([:bar], s.methods(false))
+  end
+
   class Foo
     private
     def delegate_test_private

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

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