Class: WebMock::Util::HashKeysStringifier
- Inherits:
-
Object
- Object
- WebMock::Util::HashKeysStringifier
- Defined in:
- lib/webmock/util/hash_keys_stringifier.rb
Class Method Summary collapse
Class Method Details
.stringify_keys!(arg, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/webmock/util/hash_keys_stringifier.rb', line 5 def self.stringify_keys!(arg, = {}) case arg when Array arg.map { |elem| [:deep] ? stringify_keys!(elem, ) : elem } when Hash Hash[ *arg.map { |key, value| k = key.is_a?(Symbol) ? key.to_s : key v = ([:deep] ? stringify_keys!(value, ) : value) [k,v] }.inject([]) {|r,x| r + x}] else arg end end |