PERF: more changes from inject({}) to Hash + map
This commit is contained in:
parent
4920312643
commit
42fad8c82b
|
@ -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} "
|
||||
|
|
Loading…
Reference in New Issue