A collection of key-normalization functions for various artifacts in LDAP like attribute names, objectclass OIDs, etc.
Return a copy of hash
with all of its keys normalized by #normalize_key.
# File lib/treequel/mixins.rb, line 135 def normalize_hash( hash ) hash = hash.dup hash.keys.each do |key| nkey = normalize_key( key ) hash[ nkey ] = hash.delete( key ) if key != nkey end return hash end
Normalize the given key, returning a downcased Symbol stripped of any invalid characters, and with '-' characters converted to '_'.
# File lib/treequel/mixins.rb, line 126 def normalize_key( key ) return key if key.to_s =~ Treequel::Constants::Patterns::NUMERICOID return key.to_s.downcase. gsub( /[^[:alnum:]\-_]/, '' ). gsub( '-', '_' ). to_sym end