Module ActiveLdap::Attributes::Normalizable
In: lib/active_ldap/attributes.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_44_0.png

Methods

Public Instance methods

Enforce typing: Hashes are for subtypes Arrays are for multiple entries

[Source]

    # File lib/active_ldap/attributes.rb, line 43
43:       def normalize_attribute(name, value)
44:         if name.nil?
45:           raise RuntimeError, _('The first argument, name, must not be nil. ' \
46:                                 'Please report this as a bug!')
47:         end
48: 
49:         name = normalize_attribute_name(name)
50:         [name, schema.attribute(name).normalize_value(value)]
51:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 36
36:       def normalize_attribute_name(name)
37:         name.to_s.downcase
38:       end

normalize_attribute_options

Makes the Hashized value from the full attribute name e.g. userCertificate;binary => "some_bin"

     becomes userCertificate => {"binary" => "some_bin"}

[Source]

    # File lib/active_ldap/attributes.rb, line 85
85:       def normalize_attribute_options(attr, value)
86:         return [attr, value] unless attr.match(/;/)
87: 
88:         ret_attr, *options = attr.split(/;/)
89:         [ret_attr,
90:          [options.reverse.inject(value) {|result, option| {option => result}}]]
91:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 61
61:       def unnormalize_attribute(name, values, result={})
62:         if values.empty?
63:           result[name] = []
64:         else
65:           values.each do |value|
66:             if value.is_a?(Hash)
67:               suffix, real_value = unnormalize_attribute_options(value)
68:               new_name = name + suffix
69:               result[new_name] ||= []
70:               result[new_name].concat(real_value)
71:             else
72:               result[name] ||= []
73:               result[name] << value.dup
74:             end
75:           end
76:         end
77:         result
78:       end

unnormalize_attribute_options

Unnormalizes all of the subtypes from a given set of nested hashes and returns the attribute suffix and the final true value

[Source]

     # File lib/active_ldap/attributes.rb, line 97
 97:       def unnormalize_attribute_options(value)
 98:         options = ''
 99:         ret_val = value
100:         if value.class == Hash
101:           options = ';' + value.keys[0]
102:           ret_val = value[value.keys[0]]
103:           if ret_val.class == Hash
104:             sub_options, ret_val = unnormalize_attribute_options(ret_val)
105:             options += sub_options
106:           end
107:         end
108:         ret_val = [ret_val] unless ret_val.class == Array
109:         [options, ret_val]
110:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 53
53:       def unnormalize_attributes(attributes)
54:         result = {}
55:         attributes.each do |name, values|
56:           unnormalize_attribute(name, values, result)
57:         end
58:         result
59:       end

[Validate]