summaryrefslogtreecommitdiff
path: root/logic/helpers/hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'logic/helpers/hash.rb')
-rw-r--r--logic/helpers/hash.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/logic/helpers/hash.rb b/logic/helpers/hash.rb
index 90432b5..4cb44ac 100644
--- a/logic/helpers/hash.rb
+++ b/logic/helpers/hash.rb
@@ -17,6 +17,19 @@ module NanoBot
end
end
+ def self.stringify_keys(object)
+ case object
+ when ::Hash
+ object.each_with_object({}) do |(key, value), result|
+ result[key.to_s] = stringify_keys(value)
+ end
+ when Array
+ object.map { |e| stringify_keys(e) }
+ else
+ object
+ end
+ end
+
def self.fetch(object, path)
node = object