hashlib 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hashlib.rb +15 -2
- metadata +1 -1
data/lib/hashlib.rb
CHANGED
@@ -165,15 +165,28 @@ class Hash
|
|
165
165
|
def stringify_keys()
|
166
166
|
rv = {}
|
167
167
|
each do |k, v|
|
168
|
-
|
168
|
+
if v.is_a?(Hash)
|
169
|
+
v = v.stringify_keys()
|
170
|
+
elsif v.is_a?(Array)
|
171
|
+
v = v.map(&:stringify_keys)
|
172
|
+
end
|
173
|
+
|
174
|
+
rv[k.to_s] = v
|
169
175
|
end
|
176
|
+
|
170
177
|
return rv
|
171
178
|
end
|
172
179
|
|
173
180
|
def symbolize_keys()
|
174
181
|
rv = {}
|
175
182
|
each do |k, v|
|
176
|
-
|
183
|
+
if v.is_a?(Hash)
|
184
|
+
v = v.stringify_keys()
|
185
|
+
elsif v.is_a?(Array)
|
186
|
+
v = v.map(&:stringify_keys)
|
187
|
+
end
|
188
|
+
|
189
|
+
rv[(k.to_sym rescue k)] = v
|
177
190
|
end
|
178
191
|
return rv
|
179
192
|
end
|