aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2014-08-22 11:41:07 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2014-08-22 11:41:07 -0300
commit5d7c1057684c377bc2801c8851e99ff11ab23530 (patch)
treea5c7e57cd46ff64867851199ce9b56e212843b85 /activemodel/lib/active_model
parent9b61a7eda929fcc2e2b0cd34e27d0fceafa7c389 (diff)
parent1079bb6d7dafa975fbe6b56fbf8824c84e7fca17 (diff)
downloadrails-5d7c1057684c377bc2801c8851e99ff11ab23530.tar.gz
rails-5d7c1057684c377bc2801c8851e99ff11ab23530.tar.bz2
rails-5d7c1057684c377bc2801c8851e99ff11ab23530.zip
Merge pull request #16626 from adomokos/replacing-each-with-reduce
Replacing an each with reduce
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/errors.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index fc8034f9c7..1b46727351 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -251,11 +251,9 @@ module ActiveModel
# person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}
def to_hash(full_messages = false)
if full_messages
- messages = {}
- self.messages.each do |attribute, array|
+ self.messages.each_with_object({}) do |(attribute, array), messages|
messages[attribute] = array.map { |message| full_message(attribute, message) }
end
- messages
else
self.messages.dup
end