module Leafy::Utils

Public Class Methods

stringify_keys(hash) click to toggle source
# File lib/leafy/utils.rb, line 10
def self.stringify_keys(hash)
  hash.dup.to_a.map do |pair|
    key, value = pair
    [key.to_s, value.is_a?(Hash) ? Leafy::Utils.stringify_keys(value) : value]
  end.to_h
end
symbolize_keys(hash) click to toggle source
# File lib/leafy/utils.rb, line 3
def self.symbolize_keys(hash)
  hash.dup.to_a.map do |pair|
    key, value = pair
    [key.to_sym, value.is_a?(Hash) ? Leafy::Utils.symbolize_keys(value) : value]
  end.to_h
end