aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-19 11:13:19 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-19 13:12:52 -0600
commit099af48d31bb2b5fc8e3fff39b825efff7964d55 (patch)
treea125056346c5ffe3bd348349dadb02249c00c81a /activerecord/lib/active_record/core.rb
parentdccf6da66bf4a63971e1f12b98cb1bb1fe5a9015 (diff)
downloadrails-099af48d31bb2b5fc8e3fff39b825efff7964d55.tar.gz
rails-099af48d31bb2b5fc8e3fff39b825efff7964d55.tar.bz2
rails-099af48d31bb2b5fc8e3fff39b825efff7964d55.zip
Introduce an object to aid in creation and management of `@attributes`
Mostly delegation to start, but we can start moving a lot of behavior in bulk to this object.
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index d39e5fddfe..e8e165a7c8 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -251,11 +251,10 @@ module ActiveRecord
def initialize(attributes = nil, options = {})
defaults = {}
self.class.raw_column_defaults.each do |k, v|
- default = v.duplicable? ? v.dup : v
- defaults[k] = Attribute.from_database(default, type_for_attribute(k))
+ defaults[k] = v.duplicable? ? v.dup : v
end
- @attributes = defaults
+ @attributes = self.class.attributes_builder.build_from_database(defaults)
@column_types = self.class.column_types
init_internals
@@ -325,7 +324,7 @@ module ActiveRecord
##
def initialize_dup(other) # :nodoc:
pk = self.class.primary_key
- @attributes = other.clone_attributes
+ @attributes = @attributes.dup
@attributes[pk] = Attribute.from_database(nil, type_for_attribute(pk))
run_callbacks(:initialize) unless _initialize_callbacks.empty?