Skip to content
Browse files

use each_object_with instead of inject

Issue #98
  • Loading branch information...
1 parent 0242d1c commit 68793d275d490881fe3b26269708afe7e78277cb @greyblake greyblake committed Sep 2, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/virtus/attribute/hash.rb
View
5 lib/virtus/attribute/hash.rb
@@ -91,10 +91,9 @@ def initialize(*)
# @api private
def coerce(value)
coerced = super
- return coerced unless coerced.respond_to?(:inject)
- coerced.inject(new_hash) do |hash, key_and_value|
+ return coerced unless coerced.respond_to?(:each_with_object)
+ coerced.each_with_object(new_hash) do |key_and_value, hash|
hash[key_and_value[0]] = key_and_value[1]
- hash
end
end

0 comments on commit 68793d2

Please sign in to comment.
Something went wrong with that request. Please try again.