aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-26 04:17:35 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-10-17 10:51:53 +0900
commit1198a3880bb2918bb771b55d94cfb333813744fa (patch)
tree55c7bdd9ada28997f5d08aab764622fb5256d9d9 /activerecord/lib/active_record/persistence.rb
parentbb0c02e9b5178a2833ca509494e28d85e5d3d5df (diff)
downloadrails-1198a3880bb2918bb771b55d94cfb333813744fa.tar.gz
rails-1198a3880bb2918bb771b55d94cfb333813744fa.tar.bz2
rails-1198a3880bb2918bb771b55d94cfb333813744fa.zip
Consolidate duplicated code that initializing an empty model object
`init_with` and `init_from_db` are almost the same code except decode `coder`. And also, named `init_from_db` is a little misreading, a raw values hash from the database is already converted to an attributes object by `attributes_builder.build_from_database`, so passed `attributes` in that method is just an attributes object. I renamed that method to `init_with_attributes` since the method is shared with `init_with` to initialize an empty model object.
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 8404119631..45ceb1e3ad 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -209,7 +209,7 @@ module ActiveRecord
# new instance of the class. Accepts only keys as strings.
def instantiate_instance_of(klass, attributes, column_types = {}, &block)
attributes = klass.attributes_builder.build_from_database(attributes, column_types)
- klass.allocate.init_from_db(attributes, &block)
+ klass.allocate.init_with_attributes(attributes, &block)
end
# Called by +instantiate+ to decide which class to use for a new