aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-07-30 14:26:08 -0500
committerJoshua Peek <josh@joshpeek.com>2009-07-30 17:54:02 -0500
commitd599ea27c563af2a79ccad3cabc0a1efd4c2427f (patch)
tree6738d8b33f00eae911fd424e2ab158c989ff008d /activerecord/lib/active_record/attribute_methods
parent89e9efcbe245475dec1206373755f075e17fa3e2 (diff)
downloadrails-d599ea27c563af2a79ccad3cabc0a1efd4c2427f.tar.gz
rails-d599ea27c563af2a79ccad3cabc0a1efd4c2427f.tar.bz2
rails-d599ea27c563af2a79ccad3cabc0a1efd4c2427f.zip
Move attribute_types_cached_by_default into attribute methods reading concern
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index 1178c713b4..bea332ef26 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -3,8 +3,15 @@ module ActiveRecord
module Read
extend ActiveSupport::Concern
+ ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [:datetime, :timestamp, :time, :date]
+
included do
attribute_method_suffix ""
+
+ cattr_accessor :attribute_types_cached_by_default, :instance_writer => false
+ self.attribute_types_cached_by_default = ATTRIBUTE_TYPES_CACHED_BY_DEFAULT
+
+ # Undefine id so it can be used as an attribute name
undef_method :id
end
@@ -35,6 +42,10 @@ module ActiveRecord
else
define_read_method(attr_name.to_sym, attr_name, columns_hash[attr_name])
end
+
+ if attr_name == primary_key && attr_name != "id"
+ define_read_method(:id, attr_name, columns_hash[attr_name])
+ end
end
private