github-changelog-generator/lib/github_changelog_generator/hash.rb

17 lines
437 B
Ruby
Raw Normal View History

2016-09-27 21:44:49 +00:00
# frozen_string_literal: true
class Hash
def stringify_keys_deep!
new_hash = {}
keys.each do |k|
ks = k.respond_to?(:to_s) ? k.to_s : k
new_hash[ks] = if values_at(k).first.is_a?(Hash) || values_at(k).first.is_a?(Array)
values_at(k).first.send(:stringify_keys_deep!)
else
values_at(k).first
end
end
new_hash
end
end