diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index d899f9602c658..af13b78a8e67d 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,4 +1,4 @@ -* Fix delegation in ActiveModel::Type::Registry#lookup +* Fix delegation in ActiveModel::Type::Registry#lookup and ActiveModel::Type.lookup Passing a last positional argument `{}` would be incorrectly considered as keyword argument. diff --git a/activemodel/lib/active_model/type.rb b/activemodel/lib/active_model/type.rb index 735d0e7f57a91..3a0e8abcc3f43 100644 --- a/activemodel/lib/active_model/type.rb +++ b/activemodel/lib/active_model/type.rb @@ -30,8 +30,8 @@ def register(type_name, klass = nil, &block) registry.register(type_name, klass, &block) end - def lookup(*args, **kwargs) # :nodoc: - registry.lookup(*args, **kwargs) + def lookup(...) # :nodoc: + registry.lookup(...) end def default_value # :nodoc: diff --git a/activemodel/test/cases/type_test.rb b/activemodel/test/cases/type_test.rb index 70f3f6052e691..43951e0259c4c 100644 --- a/activemodel/test/cases/type_test.rb +++ b/activemodel/test/cases/type_test.rb @@ -18,6 +18,7 @@ class TypeTest < ActiveModel::TestCase ActiveModel::Type.register(:foo, type) assert_equal type.new(:arg), ActiveModel::Type.lookup(:foo, :arg) + assert_equal type.new({}), ActiveModel::Type.lookup(:foo, {}) end end end