Sha256: 5aa1f42486f1f7c4cb6c9715b4c1b1f7da92b660f407b17680f4f3d0d8673adb
Contents?: true
Size: 1.43 KB
Versions: 10
Compression:
Stored size: 1.43 KB
Contents
module Cloudfuji class Utils #:nodoc: class << self # TODO: Make this update all the available ENV variables def refresh_env! end def array_helper(array, proc) array.collect do |value| if value.kind_of?( Hash ) deep_process_hash_keys(value, proc) elsif value.kind_of?( Array ) array_helper(array) else value end end end def deep_process_hash_keys(input_hash, proc) hash = {} input_hash.keys.each do |key| _key = proc.call(key) if input_hash[key].kind_of?(Hash) hash[_key] = deep_process_hash_keys(input_hash[key], proc) elsif input_hash[key].kind_of?(Array) hash[_key] = array_helper(input_hash[key], proc) else hash[_key] = input_hash[key] end end hash end def deep_underscore_hash_keys(input_hash) deep_process_hash_keys(input_hash, Proc.new { |key| key.to_s.underscore }) end def deep_symbolize_hash_keys(input_hash) deep_process_hash_keys(input_hash, Proc.new { |key| key.to_sym }) end def deep_stringify_hash_keys(input_hash) deep_process_hash_keys(input_hash, Proc.new { |key| key.to_s }) end def normalize_keys(input_hash) deep_symbolize_hash_keys(deep_underscore_hash_keys(input_hash)) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems