diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-20 16:20:49 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-20 16:20:49 -0700 |
commit | 4be0fc124a13704b309bb6d79da4fdfdbee67cf9 (patch) | |
tree | b9057fdbdea07b6e058f944039edaa9341df71e0 | |
parent | 784177aeeeea3265e74b2ec8c3a2929a160ba904 (diff) | |
download | rails-4be0fc124a13704b309bb6d79da4fdfdbee67cf9.tar.gz rails-4be0fc124a13704b309bb6d79da4fdfdbee67cf9.tar.bz2 rails-4be0fc124a13704b309bb6d79da4fdfdbee67cf9.zip |
use a map and flatten to avoid << calls on array
-rw-r--r-- | activerecord/lib/active_record/base.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 9c4bded1f3..053b796991 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -987,17 +987,15 @@ module ActiveRecord #:nodoc: # Similar in purpose to +expand_hash_conditions_for_aggregates+. def expand_attribute_names_for_aggregates(attribute_names) - expanded_attribute_names = [] - attribute_names.each do |attribute_name| + attribute_names.map { |attribute_name| unless (aggregation = reflect_on_aggregation(attribute_name.to_sym)).nil? - aggregate_mapping(aggregation).each do |field_attr, aggregate_attr| - expanded_attribute_names << field_attr.to_sym + aggregate_mapping(aggregation).map do |field_attr, _| + field_attr.to_sym end else - expanded_attribute_names << attribute_name.to_sym + attribute_name.to_sym end - end - expanded_attribute_names + }.flatten end def all_attributes_exists?(attribute_names) |