aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-06-09 03:24:41 -0700
committerJosé Valim <jose.valim@plataformatec.com.br>2012-06-09 03:24:41 -0700
commiteaeebc28840b06008aa9aa0e238cdc2331278a10 (patch)
tree11425d01dcc2787898b5624f42135dfa4992dea1
parent6900a4ec3e5496c3b73ad6defdd17915f2fcfdc5 (diff)
parent6e4a064256331f21b3b3107e2349f7e7adc6d8e6 (diff)
downloadrails-eaeebc28840b06008aa9aa0e238cdc2331278a10.tar.gz
rails-eaeebc28840b06008aa9aa0e238cdc2331278a10.tar.bz2
rails-eaeebc28840b06008aa9aa0e238cdc2331278a10.zip
Merge pull request #6687 from tiegz/3-2-optimizations
ActiveRecord#attributes optimization: minimize objects created
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index 06b66b5195..7fc3b2bb5d 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -181,7 +181,9 @@ module ActiveRecord
# Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
def attributes
- Hash[@attributes.map { |name, _| [name, read_attribute(name)] }]
+ attrs = {}
+ attribute_names.each { |name| attrs[name] = read_attribute(name) }
+ attrs
end
# Returns an <tt>#inspect</tt>-like string for the value of the