Module ActiveLdap::Attributes::Normalizable
In: lib/active_ldap/attributes.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] 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 Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/xml.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb Compatible 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_46_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 74
74:       def normalize_attribute(name, value)
75:         if name.nil?
76:           raise RuntimeError, _('The first argument, name, must not be nil. ' \
77:                                 'Please report this as a bug!')
78:         end
79: 
80:         name = normalize_attribute_name(name)
81:         [name, schema.attribute(name).normalize_value(value)]
82:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 67
67:       def normalize_attribute_name(name)
68:         name.to_s.downcase
69:       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 116
116:       def normalize_attribute_options(attr, value)
117:         return [attr, value] unless attr.match(/;/)
118: 
119:         ret_attr, *options = attr.split(/;/)
120:         [ret_attr,
121:          [options.reverse.inject(value) {|result, option| {option => result}}]]
122:       end

[Source]

     # File lib/active_ldap/attributes.rb, line 92
 92:       def unnormalize_attribute(name, values, result={})
 93:         if values.empty?
 94:           result[name] = []
 95:         else
 96:           values.each do |value|
 97:             if value.is_a?(Hash)
 98:               suffix, real_value = unnormalize_attribute_options(value)
 99:               new_name = name + suffix
100:               result[new_name] ||= []
101:               result[new_name].concat(real_value)
102:             else
103:               result[name] ||= []
104:               result[name] << value.dup
105:             end
106:           end
107:         end
108:         result
109:       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 128
128:       def unnormalize_attribute_options(value)
129:         options = ''
130:         ret_val = value
131:         if value.class == Hash
132:           options = ';' + value.keys[0]
133:           ret_val = value[value.keys[0]]
134:           if ret_val.class == Hash
135:             sub_options, ret_val = unnormalize_attribute_options(ret_val)
136:             options += sub_options
137:           end
138:         end
139:         ret_val = [ret_val] unless ret_val.class == Array
140:         [options, ret_val]
141:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 84
84:       def unnormalize_attributes(attributes)
85:         result = {}
86:         attributes.each do |name, values|
87:           unnormalize_attribute(name, values, result)
88:         end
89:         result
90:       end

[Validate]