Browse files

adding documentation for cached_attributes

  • Loading branch information...
1 parent cb50a28 commit 130a280ddee1f96ccf378b52c17ee742b5e54f4a Gaurav Sharma committed May 12, 2008
Showing with 4 additions and 2 deletions.
  1. +4 −2 activerecord/lib/active_record/attribute_methods.rb
6 activerecord/lib/active_record/attribute_methods.rb
@@ -104,17 +104,19 @@ def instance_method_already_implemented?(method_name)
# +cache_attributes+ allows you to declare which converted attribute values should
# be cached. Usually caching only pays off for attributes with expensive conversion
- # methods, like date columns (e.g. created_at, updated_at).
+ # methods, like time related columns (e.g. created_at, updated_at).
def cache_attributes(*attribute_names)
attribute_names.each {|attr| cached_attributes << attr.to_s}
- # returns the attributes where
+ # returns the attributes which are cached.
+ # By default time related columns with datatype <tt>:datetime, :timestamp, :time, :date</tt> are cached
def cached_attributes
@cached_attributes ||={|c| attribute_types_cached_by_default.include?(c.type)}.map(&:name).to_set
+ # returns true if the provided attribute is being cached
def cache_attribute?(attr_name)

0 comments on commit 130a280

Please sign in to comment.