From 7edade337e968fb028b2b6abfa579120eb424039 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Thu, 22 Dec 2011 19:11:11 +0000 Subject: Make read_attribute code path accessible at the class level --- activerecord/lib/active_record/base.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 432a40ea54..fa5846de39 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -469,7 +469,7 @@ module ActiveRecord #:nodoc: # # Instantiates a single new object bypassing mass-assignment security # User.new({ :first_name => 'Jamie', :is_admin => true }, :without_protection => true) def initialize(attributes = nil, options = {}) - @attributes = attributes_from_column_definition + @attributes = self.class.initialize_attributes(self.class.column_defaults.dup) @association_cache = {} @aggregation_cache = {} @attributes_cache = {} @@ -482,7 +482,6 @@ module ActiveRecord #:nodoc: @relation = nil ensure_proper_type - set_serialized_attributes populate_with_current_scope_attributes @@ -503,11 +502,9 @@ module ActiveRecord #:nodoc: # post.init_with('attributes' => { 'title' => 'hello world' }) # post.title # => 'hello world' def init_with(coder) - @attributes = coder['attributes'] + @attributes = self.class.initialize_attributes(coder['attributes']) @relation = nil - set_serialized_attributes - @attributes_cache, @previously_changed, @changed_attributes = {}, {}, {} @association_cache = {} @aggregation_cache = {} @@ -534,7 +531,7 @@ module ActiveRecord #:nodoc: _run_after_initialize_callbacks if respond_to?(:_run_after_initialize_callbacks) @changed_attributes = {} - attributes_from_column_definition.each do |attr, orig_value| + self.class.column_defaults.each do |attr, orig_value| @changed_attributes[attr] = orig_value if field_changed?(attr, orig_value, @attributes[attr]) end -- cgit v1.2.3