aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/aggregations.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-12-08 04:46:57 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-12-08 04:46:57 +0000
commitd496db1388bd0d3f43c0c35547942fb4abb4082c (patch)
tree312b01c4725b7d27be0d394345a2fae803712a53 /activerecord/lib/active_record/aggregations.rb
parente466fc45cade7cbc0ee5a0e7181e377dd3780043 (diff)
downloadrails-d496db1388bd0d3f43c0c35547942fb4abb4082c.tar.gz
rails-d496db1388bd0d3f43c0c35547942fb4abb4082c.tar.bz2
rails-d496db1388bd0d3f43c0c35547942fb4abb4082c.zip
Reloading an instance refreshes its aggregations as well as its associations. References #3024.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3242 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/aggregations.rb')
-rw-r--r--activerecord/lib/active_record/aggregations.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index 0970eaceee..314c40cfde 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -4,6 +4,12 @@ module ActiveRecord
base.extend(ClassMethods)
end
+ def clear_aggregation_cache #:nodoc:
+ self.class.reflect_on_all_aggregations.to_a.each do |assoc|
+ instance_variable_set "@#{assoc.name}", nil
+ end unless self.new_record?
+ end
+
# Active Record implements aggregation through a macro-like class method called +composed_of+ for representing attributes
# as value objects. It expresses relationships like "Account [is] composed of Money [among other things]" or "Person [is]
# composed of [an] address". Each call to the macro adds a description of how the value objects are created from the