Class: ForestAdminDatasourceToolkit::Utils::HashHelper
- Inherits:
-
Object
- Object
- ForestAdminDatasourceToolkit::Utils::HashHelper
- Defined in:
- lib/forest_admin_datasource_toolkit/utils/hash_helper.rb
Class Method Summary collapse
Class Method Details
.convert_keys(object, method = :to_sym) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/forest_admin_datasource_toolkit/utils/hash_helper.rb', line 4 def self.convert_keys(object, method = :to_sym) if object.is_a? Array object.each_with_object([]) do |value, new_array| new_array << convert_keys(value, method) end elsif object.is_a? Hash object.each_with_object({}) do |(key, value), new_hash| new_hash[key.send(method)] = value.is_a?(Hash) ? convert_keys(value, method) : value end else object end end |