diff options
Diffstat (limited to 'logic/helpers')
-rw-r--r-- | logic/helpers/hash.rb | 13 |
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 |