aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorEloy Duran <eloy.de.enige@gmail.com>2009-12-31 14:07:56 +0100
committerEloy Duran <eloy.de.enige@gmail.com>2010-01-07 13:19:48 +0100
commit2171e0a1d13a176db1e9e9dd55242fdb319b526c (patch)
treedf7594c11e84aeee8541603219a88d2a13e372e5 /activerecord/lib/active_record/reflection.rb
parentf82adc7c5addb4f9bf6b9cb3f1fcf3fb47505e53 (diff)
downloadrails-2171e0a1d13a176db1e9e9dd55242fdb319b526c.tar.gz
rails-2171e0a1d13a176db1e9e9dd55242fdb319b526c.tar.bz2
rails-2171e0a1d13a176db1e9e9dd55242fdb319b526c.zip
Cleanup some code in nested_attributes.rb, autosave_association.rb, and associations.rb with AssociationReflection#collection_association?
Also cache the result value.
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 69772bf9bb..96aac96cda 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -256,7 +256,10 @@ module ActiveRecord
# association. Returns +true+ if the +macro+ is one of +has_many+ or
# +has_and_belongs_to_many+, +false+ otherwise.
def collection_association?
- [:has_many, :has_and_belongs_to_many].include?(macro)
+ if @collection_association.nil?
+ @collection_association = [:has_many, :has_and_belongs_to_many].include?(macro)
+ end
+ @collection_association
end
private