aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/model_schema.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-03 15:14:00 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-07 14:13:46 -0800
commit5396fca1e2ab656e460713523efe3a5b1e967d30 (patch)
tree23e834917a5b694bb9ebcd4ade1998bab3470327 /activerecord/lib/active_record/model_schema.rb
parent98211755bb8145d2622b46bff9246daa607dafe4 (diff)
downloadrails-5396fca1e2ab656e460713523efe3a5b1e967d30.tar.gz
rails-5396fca1e2ab656e460713523efe3a5b1e967d30.tar.bz2
rails-5396fca1e2ab656e460713523efe3a5b1e967d30.zip
give each PG type a `type` method and decortate tz attributes
Diffstat (limited to 'activerecord/lib/active_record/model_schema.rb')
-rw-r--r--activerecord/lib/active_record/model_schema.rb22
1 files changed, 17 insertions, 5 deletions
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