1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix delegate_missing_to to allow keyword arguments

This commit is contained in:
Ryuta Kamizono 2020-02-28 04:20:01 +09:00
parent 7205b9f4a6
commit 12e48544cf
2 changed files with 9 additions and 0 deletions

View file

@ -324,6 +324,7 @@ class Module
end
end
end
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
RUBY
end
end

View file

@ -24,6 +24,10 @@ Someone = Struct.new(:name, :place) do
self::FAILED_DELEGATE_LINE_2 = __LINE__ + 1
delegate :bar, to: :place, allow_nil: true
def kw_send(method:)
public_send(method)
end
private
def private_name
"Private"
@ -385,6 +389,10 @@ class ModuleTest < ActiveSupport::TestCase
assert_equal "David", DecoratedReserved.new(@david).name
end
def test_delegate_missing_to_with_keyword_methods
assert_equal "David", DecoratedReserved.new(@david).kw_send(method: "name")
end
def test_delegate_missing_to_does_not_delegate_to_private_methods
e = assert_raises(NoMethodError) do
DecoratedReserved.new(@david).private_name