aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--lib/forwardable.rb2
2 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index eeb1928b1a..c32408eaa9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Tue Jan 12 19:52:19 2016 sorah (Shota Fukumori) <her@sorah.jp>
+
+ * 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@it.aoyama.ac.jp>
* string.c: made a variable name more grammatically correct
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 390e1460cf..2ea0aa1d77 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -178,6 +178,7 @@ module Forwardable
# 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
# 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