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

ruby-changes:41437

From: sorah <ko1@a...>
Date: Tue, 12 Jan 2016 20:19:01 +0900 (JST)
Subject: [ruby-changes:41437] sorah:r53511 (trunk): * lib/forwardable.rb: Convert given accessors to String.

sorah	2016-01-12 20:19:25 +0900 (Tue, 12 Jan 2016)

  New Revision: 53511

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53511

  Log:
    * lib/forwardable.rb: Convert given accessors to String.
    
      r53381 changed to accept only Symbol or String for accessors, but
      there are several rubygems that pass classes (e.g. Array,
      Hash, ...) as accessors. Prior r53381, it was accepted because Class#to_s
      returns its class name. After r53381 given accessors are checked
      with define_method, but it accepts only Symbol or String, otherwise
      raises TypeError.
    
          def_delegator Foo, :some_method
    
      This change is to revert unwanted incompatibility. But this behavior
      may change in the future.

  Modified files:
    trunk/ChangeLog
    trunk/lib/forwardable.rb
Index: lib/forwardable.rb
===================================================================
--- lib/forwardable.rb	(revision 53510)
+++ lib/forwardable.rb	(revision 53511)
@@ -178,6 +178,7 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L178
   #   q.push 23  #=> NoMethodError
   #
   def def_instance_delegator(accessor, method, ali = method)
+    accessor = accessor.to_s
     if method_defined?(accessor) || private_method_defined?(accessor)
       accessor = "#{accessor}()"
     end
@@ -279,6 +280,7 @@ module SingleForwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L280
   # the method of the same name in _accessor_).  If _new_name_ is
   # provided, it is used as the name for the delegate method.
   def def_single_delegator(accessor, method, ali = method)
+    accessor = accessor.to_s
     if method_defined?(accessor) || private_method_defined?(accessor)
       accessor = "#{accessor}()"
     end
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53510)
+++ ChangeLog	(revision 53511)
@@ -1,3 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jan 12 19:52:19 2016  sorah (Shota Fukumori)  <her@s...>
+
+	* lib/forwardable.rb: Convert given accessors to String.
+
+	  r53381 changed to accept only Symbol or String for accessors, but
+	  there are several rubygems that pass classes (e.g. Array,
+	  Hash, ...) as accessors. Prior r53381, it was accepted because Class#to_s
+	  returns its class name. After r53381 given accessors are checked
+	  with define_method, but it accepts only Symbol or String, otherwise
+	  raises TypeError.
+
+	      def_delegator Foo, :some_method
+
+	  This change is to revert unwanted incompatibility. But this behavior
+	  may change in the future.
+
 Mon Jan 12 18:41:41 2016  Martin Duerst  <duerst@i...>
 
 	* string.c: made a variable name more grammatically correct

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

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