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

enhance active model assignment

This commit is contained in:
shotat 2017-06-14 09:13:26 +09:00
parent 326914dd3a
commit 285cba022c

View file

@ -42,8 +42,9 @@ module ActiveModel
end
def _assign_attribute(k, v)
if respond_to?("#{k}=")
public_send("#{k}=", v)
setter = "#{k}="
if respond_to?(setter)
public_send(setter, v)
else
raise UnknownAttributeError.new(self, k)
end