Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ext/hash_patch.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#keys_to_s ⇒ Hash
Converts keys to Strings.
Instance Method Details
#keys_to_s ⇒ Hash
Converts keys to Strings. Useful for dealing with SDP::Parser
results (which subclasses Parslet::Parser
), which returns Parslet::Slice
objects in place of String
objects, which isn’t helpful in this case.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ext/hash_patch.rb', line 7 def keys_to_s self.each do |k, v| case v when Hash v.keys_to_s when Array v.each do |element| element.keys_to_s if element.is_a? Hash end else self[k] = v.to_s end end self end |