mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
use grep instead of select + is_a?
This commit is contained in:
parent
4be0fc124a
commit
828bb94d5a
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue