diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-22 19:11:11 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-22 19:24:16 +0000 |
commit | 7edade337e968fb028b2b6abfa579120eb424039 (patch) | |
tree | f44f5381296ac54920a8a29f528cbcbec4bedd2f /activerecord/lib/active_record/base.rb | |
parent | 89e2647da6fade8397963fc0c0159eee4f3fd842 (diff) | |
download | rails-7edade337e968fb028b2b6abfa579120eb424039.tar.gz rails-7edade337e968fb028b2b6abfa579120eb424039.tar.bz2 rails-7edade337e968fb028b2b6abfa579120eb424039.zip |
Make read_attribute code path accessible at the class level
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 9 |
1 files changed, 3 insertions, 6 deletions
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 |