diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-01-24 06:38:23 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-01-24 06:38:23 -0700 |
commit | 9bf9097973c083b23305fe3dddfb359f7049fec9 (patch) | |
tree | b2bac4f265e248a67418d10a90437013e93c6341 /activemodel/lib | |
parent | 847395a04df52a389823ff4367c4b002cdbb5c6a (diff) | |
parent | 5bdb42159ec461d678652319da14b4a59bfafd27 (diff) | |
download | rails-9bf9097973c083b23305fe3dddfb359f7049fec9.tar.gz rails-9bf9097973c083b23305fe3dddfb359f7049fec9.tar.bz2 rails-9bf9097973c083b23305fe3dddfb359f7049fec9.zip |
Merge pull request #18663 from egilburg/reuse-attribute-assignment
Use attribute assignment module logic during ActiveModel initialization.
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/model.rb | 7 |
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 |