diff options
author | Gaurav Sharma <gaurav@norbauer.com> | 2008-05-12 18:00:19 +0530 |
---|---|---|
committer | Gaurav Sharma <gaurav@norbauer.com> | 2008-05-12 18:00:19 +0530 |
commit | 130a280ddee1f96ccf378b52c17ee742b5e54f4a (patch) | |
tree | 1463e622a1631ad9f241ccbbe78626a7accf6237 | |
parent | cb50a2880759f311148abda55ab60be772b8aa51 (diff) | |
download | rails-130a280ddee1f96ccf378b52c17ee742b5e54f4a.tar.gz rails-130a280ddee1f96ccf378b52c17ee742b5e54f4a.tar.bz2 rails-130a280ddee1f96ccf378b52c17ee742b5e54f4a.zip |
adding documentation for cached_attributes
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 2db27226f2..ac40e4f987 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -104,17 +104,19 @@ module ActiveRecord # +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} end - # 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 ||= columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map(&:name).to_set end + # returns true if the provided attribute is being cached def cache_attribute?(attr_name) cached_attributes.include?(attr_name) end |