def initialize(attributes=nil)
init_base
@new_entry = true
initial_classes = required_classes | recommended_classes
if attributes.nil?
apply_object_class(initial_classes)
elsif attributes.is_a?(String) or attributes.is_a?(Array)
apply_object_class(initial_classes)
self.dn = attributes
elsif attributes.is_a?(Hash)
classes, attributes = extract_object_class(attributes)
apply_object_class(classes | initial_classes)
normalized_attributes = {}
attributes.each do |key, value|
real_key = to_real_attribute_name(key) || key
normalized_attributes[real_key] = value
end
self.dn = normalized_attributes[dn_attribute]
self.attributes = normalized_attributes
else
message = _("'%s' must be either nil, DN value as String or Array " \
"or attributes as Hash") % attributes.inspect
raise ArgumentError, message
end
yield self if block_given?
assert_dn_attribute
end