aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/model.rb
diff options
context:
space:
mode:
authorEugene Gilburg <eugene.gilburg@gmail.com>2015-01-23 14:36:43 -0800
committerEugene Gilburg <eugene.gilburg@gmail.com>2015-01-23 14:42:47 -0800
commit5bdb42159ec461d678652319da14b4a59bfafd27 (patch)
tree6b45ce49afbceb3297ca6eb2a559ad8d461a9ddf /activemodel/lib/active_model/model.rb
parent8c83bd0732fc526e69cd5c348cb9d9842ae60c99 (diff)
downloadrails-5bdb42159ec461d678652319da14b4a59bfafd27.tar.gz
rails-5bdb42159ec461d678652319da14b4a59bfafd27.tar.bz2
rails-5bdb42159ec461d678652319da14b4a59bfafd27.zip
use attribute assignment module logic during active model initialization
Diffstat (limited to 'activemodel/lib/active_model/model.rb')
-rw-r--r--activemodel/lib/active_model/model.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/model.rb b/activemodel/lib/active_model/model.rb
index d51d6ddcc9..dac8d549a7 100644
--- a/activemodel/lib/active_model/model.rb
+++ b/activemodel/lib/active_model/model.rb
@@ -57,6 +57,7 @@ module ActiveModel
# (see below).
module Model
extend ActiveSupport::Concern
+ include ActiveModel::AttributeAssignment
include ActiveModel::Validations
include ActiveModel::Conversion
@@ -75,10 +76,8 @@ module ActiveModel
# person = Person.new(name: 'bob', age: '18')
# person.name # => "bob"
# person.age # => "18"
- def initialize(params={})
- params.each do |attr, value|
- self.public_send("#{attr}=", value)
- end if params
+ def initialize(attributes={})
+ assign_attributes(attributes) if attributes
super()
end