Merge pull request #49836 from skipkayhil/hm-assign-attribute-respond-to

Remove respond_to? in assign_attribute happy path
This commit is contained in:
Jonathan Hefner 2023-10-29 15:43:04 -05:00 committed by GitHub
commit ed2839dd9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -45,8 +45,10 @@ module ActiveModel
def _assign_attribute(k, v)
setter = :"#{k}="
public_send(setter, v)
rescue NoMethodError
if respond_to?(setter)
public_send(setter, v)
raise
else
raise UnknownAttributeError.new(self, k.to_s)
end