summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2019-08-15 15:21:55 -0700
committerHiroshi SHIBATA <[email protected]>2019-10-26 09:25:06 +0900
commitd00551a7bb1d5dbabb0a8c95d6bd2d9d4e86934a ()
treeb854d144bee1428eff5ad4a2a81e86adfd2142d1
parentb15e0983f7504c4688afce0ee29a2f4746b6631a (diff)
[ruby/forwardable] Make def_{instance,single}_delegators skip :__send__ and :__id__
Previously, __send__ and __id__ were skipped if provided as strings, but not skipped if provided as symbols. Fixes Ruby Bug 8855. https://.com/ruby/forwardable/commit/2e61c8c66c
-rw-r--r--lib/forwardable.rb10
-rw-r--r--test/test_forwardable.rb24
2 files changed, 28 insertions, 6 deletions
@@ -149,9 +149,8 @@ module Forwardable
# def_delegator :@records, :map
#
def def_instance_delegators(accessor, *methods)
- methods.delete("__send__")
- methods.delete("__id__")
- for method in methods
def_instance_delegator(accessor, method)
end
end
@@ -286,9 +285,8 @@ module SingleForwardable
# def_delegator :@records, :map
#
def def_single_delegators(accessor, *methods)
- methods.delete("__send__")
- methods.delete("__id__")
- for method in methods
def_single_delegator(accessor, method)
end
end
@@ -107,6 +107,18 @@ class TestForwardable < Test::Unit::TestCase
end
end
def test_instance_delegate
%i[delegate instance_delegate].each do |m|
cls = forwardable_class do
@@ -215,6 +227,18 @@ class TestForwardable < Test::Unit::TestCase
end
end
def test_obj_single_delegate
%i[delegate single_delegate].each do |m|
obj = single_forwardable_object do