aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorshotat <shotat@users.noreply.github.com>2017-06-14 09:13:26 +0900
committershotat <shotat@users.noreply.github.com>2017-06-14 10:31:12 +0900
commit285cba022ce37977f977376a20ca866197ef33bd (patch)
tree669fb6abd91bc152459c1a002f27e62279a0bd1b /activemodel
parent326914dd3a15e04851c9ef4a47edeb3dad2ec381 (diff)
downloadrails-285cba022ce37977f977376a20ca866197ef33bd.tar.gz
rails-285cba022ce37977f977376a20ca866197ef33bd.tar.bz2
rails-285cba022ce37977f977376a20ca866197ef33bd.zip
enhance active model assignment
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/attribute_assignment.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/attribute_assignment.rb b/activemodel/lib/active_model/attribute_assignment.rb
index 930e89d611..a0a6de8dd7 100644
--- a/activemodel/lib/active_model/attribute_assignment.rb
+++ b/activemodel/lib/active_model/attribute_assignment.rb
@@ -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