diff options
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/attribute_assignment.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/attribute_assignment.rb b/activemodel/lib/active_model/attribute_assignment.rb index 930e89d611..aa931119ff 100644 --- a/activemodel/lib/active_model/attribute_assignment.rb +++ b/activemodel/lib/active_model/attribute_assignment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/hash/keys" module ActiveModel @@ -42,8 +44,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 |