aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/read.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-07 11:51:30 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-07 13:51:53 -0800
commit00b62ab73bef05126fdfb72291beee60898c4f8e (patch)
treeba5f83bc5ce6fdfe8af427b61a424109af045bfe /activerecord/lib/active_record/attribute_methods/read.rb
parentab6ebcceb1052f55ff8a93cf2a80b79f32c50ee9 (diff)
downloadrails-00b62ab73bef05126fdfb72291beee60898c4f8e.tar.gz
rails-00b62ab73bef05126fdfb72291beee60898c4f8e.tar.bz2
rails-00b62ab73bef05126fdfb72291beee60898c4f8e.zip
moving column types to an ivar on the result
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/read.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index 66f4b0b6c6..a52d36aad8 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -125,7 +125,11 @@ module ActiveRecord
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
def read_attribute(attr_name)
- self.class.type_cast_attribute(attr_name, @attributes, @attributes_cache)
+ if @columns_hash.key? attr_name
+ @columns_hash[attr_name].type_cast @attributes[attr_name]
+ else
+ self.class.type_cast_attribute(attr_name, @attributes, @attributes_cache)
+ end
end
private