diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 14:02:47 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 14:02:47 -0700 |
commit | 2faa8bbe1152d0c924e3a38cabf9251e2fb972d6 (patch) | |
tree | 2e3e0f27845c615aa62a95d6fa61e07497c022e0 | |
parent | c0c8a04efc16d3737b3a153b1ee4f75065c3193a (diff) | |
download | rails-2faa8bbe1152d0c924e3a38cabf9251e2fb972d6.tar.gz rails-2faa8bbe1152d0c924e3a38cabf9251e2fb972d6.tar.bz2 rails-2faa8bbe1152d0c924e3a38cabf9251e2fb972d6.zip |
refactor a couple injects to map + Hash[]
-rw-r--r-- | activerecord/lib/active_record/base.rb | 7 |
1 files changed, 2 insertions, 5 deletions
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) |