From f936a1f100e75082081e782e5cceb272885c2df7 Mon Sep 17 00:00:00 2001 From: Eric Chapweske Date: Sat, 17 Oct 2009 12:37:15 -0500 Subject: Refactoring attributes/types [#3348 state:resolved] Signed-off-by: Joshua Peek --- .../lib/active_record/attribute_methods/before_type_cast.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'activerecord/lib/active_record/attribute_methods/before_type_cast.rb') diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb index a4e144f233..74921241f7 100644 --- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb +++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb @@ -8,25 +8,18 @@ module ActiveRecord end def read_attribute_before_type_cast(attr_name) - @attributes[attr_name] + _attributes.without_typecast[attr_name] end # Returns a hash of attributes before typecasting and deserialization. def attributes_before_type_cast - self.attribute_names.inject({}) do |attrs, name| - attrs[name] = read_attribute_before_type_cast(name) - attrs - end + _attributes.without_typecast end private # Handle *_before_type_cast for method_missing. def attribute_before_type_cast(attribute_name) - if attribute_name == 'id' - read_attribute_before_type_cast(self.class.primary_key) - else - read_attribute_before_type_cast(attribute_name) - end + read_attribute_before_type_cast(attribute_name) end end end -- cgit v1.2.3