Configurability::Config::

DataUtilities module

A collection of data-structure-manipulation functions. :todo: Replace with transform_keys after 2.4’s EOL

Public Instance Methods

stringify_keys( hash )

Return a version of the given hash with its keys transformed into Strings from whatever they were before.

# File lib/configurability/config.rb, line 315
def stringify_keys( hash )
        newhash = {}
        hash.each do |key,val|
                if val.is_a?( Hash )
                        newhash[ key.to_s ] = stringify_keys( val )
                else
                        newhash[ key.to_s ] = val
                end
        end

        return newhash
end
symbolify_keys( hash )

Return a duplicate of the given hash with its identifier-like keys transformed into symbols from whatever they were before.

# File lib/configurability/config.rb, line 297
def symbolify_keys( hash )
        newhash = {}
        hash.each do |key,val|
                key = key.to_sym if key.respond_to?( :to_sym )

                if val.is_a?( Hash )
                        newhash[ key ] = symbolify_keys( val )
                else
                        newhash[ key ] = val
                end
        end

        return newhash
end