From 5396fca1e2ab656e460713523efe3a5b1e967d30 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 3 Feb 2012 15:14:00 -0800 Subject: give each PG type a `type` method and decortate tz attributes --- activerecord/lib/active_record/model_schema.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/model_schema.rb') diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 5486e192e4..b8764217d3 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -206,12 +206,24 @@ module ActiveRecord @columns_hash ||= Hash[columns.map { |c| [c.name, c] }] end - def column_types - @column_types ||= columns_hash.dup.tap { |x| - serialized_attributes.keys.each do |key| - x[key] = AttributeMethods::Serialization::Type.new(x[key]) + def column_types # :nodoc: + @column_types ||= decorate_columns(columns_hash.dup) + end + + def decorate_columns(columns_hash) # :nodoc: + return if columns_hash.empty? + + serialized_attributes.keys.each do |key| + columns_hash[key] = AttributeMethods::Serialization::Type.new(columns_hash[key]) + end + + columns_hash.each do |name, col| + if create_time_zone_conversion_attribute?(name, col) + columns_hash[name] = AttributeMethods::TimeZoneConversion::Type.new(col) end - } + end + + columns_hash end # Returns a hash where the keys are column names and the values are -- cgit v1.2.3