Module ActiveLdap::Attributes::Normalizable
In: lib/active_ldap/attributes.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid DistinguishedNameNotSetError EntryNotFound LdapError SaveError StrongAuthenticationRequired NotImplemented 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] Base DistinguishedName Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Normalizable Common Find LDIF Delete Update ActiveRecord::Callbacks GetText Parser 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 ActiveRecord::Validations 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 ClassMethods Normalizable Attributes Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Configuration ClassMethods ObjectClass ClassMethods Callbacks lib/active_ldap/get_text/parser.rb GetText lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/base.rb lib/active_ldap/adapter/jndi.rb Adapter Validations GetTextFallback Helper 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 78
78:       def normalize_attribute(name, value)
79:         if name.nil?
80:           raise RuntimeError, _('The first argument, name, must not be nil. ' \
81:                                 'Please report this as a bug!')
82:         end
83: 
84:         name = normalize_attribute_name(name)
85:         [name, schema.attribute(name).normalize_value(value)]
86:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 71
71:       def normalize_attribute_name(name)
72:         name.to_s.downcase
73:       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 123
123:       def normalize_attribute_options(attr, value)
124:         return [attr, value] unless attr.match(/;/)
125: 
126:         ret_attr, *options = attr.split(/;/)
127:         [ret_attr,
128:          [options.reverse.inject(value) {|result, option| {option => result}}]]
129:       end

[Source]

     # File lib/active_ldap/attributes.rb, line 96
 96:       def unnormalize_attribute(name, values, result={})
 97:         if values.empty?
 98:           result[name] = []
 99:         else
100:           values.each do |value|
101:             if value.is_a?(Hash)
102:               suffix, real_value = unnormalize_attribute_options(value)
103:               new_name = name + suffix
104:               unnormalize_attribute(new_name, real_value, result)
105:             else
106:               result[name] ||= []
107:               if value.is_a?(DN)
108:                 result[name] << value.to_s
109:               else
110:                 result[name] << value.dup
111:               end
112:             end
113:           end
114:         end
115:         result
116:       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 135
135:       def unnormalize_attribute_options(value)
136:         options = ''
137:         ret_val = value
138:         if value.class == Hash
139:           options = ';' + value.keys[0]
140:           ret_val = value[value.keys[0]]
141:           if ret_val.class == Hash
142:             sub_options, ret_val = unnormalize_attribute_options(ret_val)
143:             options += sub_options
144:           end
145:         end
146:         ret_val = [ret_val] unless ret_val.class == Array
147:         [options, ret_val]
148:       end

[Source]

    # File lib/active_ldap/attributes.rb, line 88
88:       def unnormalize_attributes(attributes)
89:         result = {}
90:         attributes.each do |name, values|
91:           unnormalize_attribute(name, values, result)
92:         end
93:         result
94:       end

[Validate]