Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delegation in ActiveModel::Type.lookup #42289

Merged
merged 2 commits into from May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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.

Expand Down
4 changes: 2 additions & 2 deletions activemodel/lib/active_model/type.rb
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions activemodel/test/cases/type_test.rb
Expand Up @@ -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