aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomK32 <tomk32@tomk32.de>2008-05-12 19:18:13 +0200
committerTomK32 <tomk32@tomk32.de>2008-05-12 19:18:13 +0200
commite9a0526d5b3fc28a81eb47dfb5f6086112d90362 (patch)
tree046ed90c14d4872c89feeb2cf7f0d9fa57e8ca83
parent164c9586480f0a02522ea15ec7fb42c6a783a74d (diff)
parent9d0900c7dffcd95339ace815192d4778cd04dc09 (diff)
downloadrails-e9a0526d5b3fc28a81eb47dfb5f6086112d90362.tar.gz
rails-e9a0526d5b3fc28a81eb47dfb5f6086112d90362.tar.bz2
rails-e9a0526d5b3fc28a81eb47dfb5f6086112d90362.zip
Merge branch 'master' of git://github.com/lifo/docrails
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb6
-rw-r--r--activesupport/lib/active_support/core_ext/module/attr_internal.rb6
2 files changed, 7 insertions, 5 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
diff --git a/activesupport/lib/active_support/core_ext/module/attr_internal.rb b/activesupport/lib/active_support/core_ext/module/attr_internal.rb
index e0be31090c..b66c0d7500 100644
--- a/activesupport/lib/active_support/core_ext/module/attr_internal.rb
+++ b/activesupport/lib/active_support/core_ext/module/attr_internal.rb
@@ -1,19 +1,19 @@
class Module
- # Declare an attribute reader backed by an internally-named instance variable.
+ # Declares an attribute reader backed by an internally-named instance variable.
def attr_internal_reader(*attrs)
attrs.each do |attr|
module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
end
end
- # Declare an attribute writer backed by an internally-named instance variable.
+ # Declares an attribute writer backed by an internally-named instance variable.
def attr_internal_writer(*attrs)
attrs.each do |attr|
module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
end
end
- # Declare an attribute reader and writer backed by an internally-named instance
+ # Declares an attribute reader and writer backed by an internally-named instance
# variable.
def attr_internal_accessor(*attrs)
attr_internal_reader(*attrs)