Skip to content

Commit

Permalink
use grep instead of select + is_a?
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 20, 2010
1 parent 4be0fc1 commit 828bb94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def reflections

# 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).
Expand All @@ -58,7 +58,7 @@ def reflect_on_aggregation(aggregation)
# 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

Expand Down

0 comments on commit 828bb94

Please sign in to comment.