PERF: more changes from inject({}) to Hash + map

This commit is contained in:
Santiago Pastorino 2010-10-03 15:03:59 -02:00
parent 4920312643
commit 42fad8c82b
1 changed files with 1 additions and 1 deletions

View File

@ -13,7 +13,7 @@ module ActiveResource
# or not (by passing true)
def from_array(messages, save_cache = false)
clear unless save_cache
humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) }
humanized_attributes = Hash[@base.attributes.keys.map { |attr_name| [attr_name.humanize, attr_name] }]
messages.each do |message|
attr_message = humanized_attributes.keys.detect do |attr_name|
if message[0, attr_name.size + 1] == "#{attr_name} "