diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-09-20 12:59:31 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-09-20 12:59:33 -0300 |
commit | da400fbb0ba6a130237d17cdd58c860be02294ad (patch) | |
tree | 961a48e1cf4f9bfb5dca8df1cbb781c0afb63d34 /activerecord/lib | |
parent | 883fa8f938731e43182a803bedc89fd503a76306 (diff) | |
download | rails-da400fbb0ba6a130237d17cdd58c860be02294ad.tar.gz rails-da400fbb0ba6a130237d17cdd58c860be02294ad.tar.bz2 rails-da400fbb0ba6a130237d17cdd58c860be02294ad.zip |
Freeze columns only once per Result
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/result.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 8905137142..425b9b41d8 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -53,12 +53,15 @@ module ActiveRecord private def hash_rows - @hash_rows ||= @rows.map { |row| - # We freeze the strings to prevent them getting duped when - # used as keys in ActiveRecord::Model's @attributes hash - columns = @columns.map { |c| c.freeze } - Hash[columns.zip(row)] - } + @hash_rows ||= + begin + # We freeze the strings to prevent them getting duped when + # used as keys in ActiveRecord::Model's @attributes hash + columns = @columns.map { |c| c.dup.freeze } + @rows.map { |row| + Hash[columns.zip(row)] + } + end end end end |