aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-20 16:41:50 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-20 16:41:50 -0700
commit828bb94d5a41695d30cb46ccafb152c98cdeae0a (patch)
tree350c09ad30a9535587fcbe8e9002605f4f4e80a9
parent4be0fc124a13704b309bb6d79da4fdfdbee67cf9 (diff)
downloadrails-828bb94d5a41695d30cb46ccafb152c98cdeae0a.tar.gz
rails-828bb94d5a41695d30cb46ccafb152c98cdeae0a.tar.bz2
rails-828bb94d5a41695d30cb46ccafb152c98cdeae0a.zip
use grep instead of select + is_a?
-rw-r--r--activerecord/lib/active_record/reflection.rb4
1 files changed, 2 insertions, 2 deletions
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