Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 42fad8c82b3ba6f86c84f06645cc1e39a8a776dd 1 parent 4920312
@spastorino spastorino authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  activeresource/lib/active_resource/validations.rb
View
2  activeresource/lib/active_resource/validations.rb
@@ -13,7 +13,7 @@ class Errors < ActiveModel::Errors
# 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} "
Please sign in to comment.
Something went wrong with that request. Please try again.