Treequel::

Normalization

module

A collection of key-normalization functions for various artifacts in LDAP like attribute names, objectclass OIDs, etc.

Public Instance Methods

anchor
normalize_hash( hash )

Return a copy of hash with all of its keys normalized by normalize_key.

# File lib/treequel/mixins.rb, line 134
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
anchor
normalize_key( key )

Normalize the given key, returning a downcased Symbol stripped of any invalid characters, and with '-' characters converted to '_'.

# File lib/treequel/mixins.rb, line 125
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