From 2faa8bbe1152d0c924e3a38cabf9251e2fb972d6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 8 Sep 2010 14:02:47 -0700 Subject: refactor a couple injects to map + Hash[] --- activerecord/lib/active_record/base.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index b4d0da9f78..fe888ca369 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -664,7 +664,7 @@ module ActiveRecord #:nodoc: # Returns a hash of column objects for the table associated with this class. def columns_hash - @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash } + @columns_hash ||= Hash[columns.map { |column| [column.name, column] }] end # Returns an array of column names as strings. @@ -1793,10 +1793,7 @@ MSG end def quote_columns(quoter, hash) - hash.inject({}) do |quoted, (name, value)| - quoted[quoter.quote_column_name(name)] = value - quoted - end + Hash[hash.map { |name, value| [quoter.quote_column_name(name), value] }] end def quoted_comma_pair_list(quoter, hash) -- cgit v1.2.3