lib/mashed/stringy_hash.rb in mashed-0.4.0 vs lib/mashed/stringy_hash.rb in mashed-0.5.0
- old
+ new
@@ -1,10 +1,13 @@
require 'delegate'
module Mashed
module ExtendHash
def stringify
- StringyHash.new(dup.each_with_object({}) { |(k,v), h| h[k.to_s] = v })
+ StringyHash.new(dup.each_with_object({}) do |(k,v), h|
+ v = v.stringify if v.respond_to?(:stringify)
+ h[k.to_s] = v
+ end)
end
end
class StringyHash < SimpleDelegator
def stringify