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:
parent
7205b9f4a6
commit
12e48544cf
2 changed files with 9 additions and 0 deletions
|
@ -324,6 +324,7 @@ class Module
|
|||
end
|
||||
end
|
||||
end
|
||||
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue