From 828bb94d5a41695d30cb46ccafb152c98cdeae0a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 20 Oct 2010 16:41:50 -0700 Subject: use grep instead of select + is_a? --- activerecord/lib/active_record/reflection.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index db18fb7c0f..a2260e9a19 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -36,7 +36,7 @@ module ActiveRecord # Returns an array of AggregateReflection objects for all the aggregations in the class. def reflect_on_all_aggregations - reflections.values.select { |reflection| reflection.is_a?(AggregateReflection) } + reflections.values.grep(AggregateReflection) end # Returns the AggregateReflection object for the named +aggregation+ (use the symbol). @@ -58,7 +58,7 @@ module ActiveRecord # Account.reflect_on_all_associations(:has_many) # returns an array of all has_many associations # def reflect_on_all_associations(macro = nil) - association_reflections = reflections.values.select { |reflection| reflection.is_a?(AssociationReflection) } + association_reflections = reflections.values.grep(AssociationReflection) macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections end -- cgit v1.2.3