Class Index [+]

Quicksearch

ActiveLdap::Attributes::Normalizable

Public Instance Methods

normalize_attribute(name, value) click to toggle source

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

    # 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. '                                  'Please report this as a bug!')
81:         end
82: 
83:         name = normalize_attribute_name(name)
84:         [name, schema.attribute(name).normalize_value(value)]
85:       end
normalize_attribute_name(name) click to toggle 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(attr, value) click to toggle source

normalize_attribute_options

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

     becomes userCertificate => {"binary" => "some_bin"}
     # 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
unnormalize_attribute(name, values, result={}) click to toggle 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(value) click to toggle source

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

     # 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
unnormalize_attributes(attributes) click to toggle 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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.