aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-20 16:17:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-20 16:17:15 -0700
commit784177aeeeea3265e74b2ec8c3a2929a160ba904 (patch)
tree90bae017d4494a2f8505ba5e50c48886a10df93d /activerecord
parent7f444a3db68c9538544f8e38c678a165a00642e3 (diff)
downloadrails-784177aeeeea3265e74b2ec8c3a2929a160ba904.tar.gz
rails-784177aeeeea3265e74b2ec8c3a2929a160ba904.tar.bz2
rails-784177aeeeea3265e74b2ec8c3a2929a160ba904.zip
only call `column_methods_hash` once, use array math for faster test of existence
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 630bf7fe85..9c4bded1f3 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -991,19 +991,18 @@ module ActiveRecord #:nodoc:
attribute_names.each do |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
+ expanded_attribute_names << field_attr.to_sym
end
else
- expanded_attribute_names << attribute_name
+ expanded_attribute_names << attribute_name.to_sym
end
end
expanded_attribute_names
end
def all_attributes_exists?(attribute_names)
- expand_attribute_names_for_aggregates(attribute_names).all? { |name|
- column_methods_hash.include?(name.to_sym)
- }
+ (expand_attribute_names_for_aggregates(attribute_names) -
+ column_methods_hash.keys).empty?
end
protected