Skip to content

Commit

Permalink
use each_object_with instead of inject
Browse files Browse the repository at this point in the history
Issue #98
  • Loading branch information
greyblake committed Sep 2, 2012
1 parent 0242d1c commit 68793d2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/virtus/attribute/hash.rb
Expand Up @@ -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

Expand Down

0 comments on commit 68793d2

Please sign in to comment.