From 2171e0a1d13a176db1e9e9dd55242fdb319b526c Mon Sep 17 00:00:00 2001 From: Eloy Duran Date: Thu, 31 Dec 2009 14:07:56 +0100 Subject: Cleanup some code in nested_attributes.rb, autosave_association.rb, and associations.rb with AssociationReflection#collection_association? Also cache the result value. --- activerecord/lib/active_record/reflection.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/reflection.rb') 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 -- cgit v1.2.3