Module: ActiveLdap::Ldif::Attributes

Defined in:
lib/active_ldap/ldif.rb

Class Method Summary collapse

Class Method Details

.encode(attributes) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/active_ldap/ldif.rb', line 9

def encode(attributes)
  return "" if attributes.empty?

  result = ""
  normalize(attributes).sort_by {|name,| name}.each do |name, values|
    values.each do |options, value|
      result << Attribute.encode([name, *options].join(";"), value)
    end
  end
  result
end

.normalize(attributes) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/active_ldap/ldif.rb', line 21

def normalize(attributes)
  result = {}
  attributes.each do |name, values|
    result[name] = Attribute.normalize_value(values).sort
  end
  result
end