Redleaf::HashUtilities

A collection of utilities for working with Hashes.

Constants

HashMergeFunction

Recursive hash-merge function

Public Instance Methods

internify_keys( hash ) click to toggle source

Alias for #symbolify_keys

stringify_keys( hash ) click to toggle source

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

     # File lib/redleaf/mixins.rb, line 111
111:         def stringify_keys( hash )
112:             newhash = {}
113: 
114:             hash.each do |key,val|
115:                 if val.is_a?( Hash )
116:                     newhash[ key.to_s ] = stringify_keys( val )
117:                 else
118:                     newhash[ key.to_s ] = val
119:                 end
120:             end
121: 
122:             return newhash
123:         end
symbolify_keys( hash ) click to toggle source

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

     # File lib/redleaf/mixins.rb, line 128
128:         def symbolify_keys( hash )
129:             newhash = {}
130: 
131:             hash.each do |key,val|
132:                 keysym = key.to_s.dup.untaint.to_sym
133: 
134:                 if val.is_a?( Hash )
135:                     newhash[ keysym ] = symbolify_keys( val )
136:                 else
137:                     newhash[ keysym ] = val
138:                 end
139:             end
140: 
141:             return newhash
142:         end
Also aliased as: internify_keys

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.