Module: ActiveLdap::ObjectClass — activeldap - ActiveLdap

Module: ActiveLdap::ObjectClass

Defined in:
lib/active_ldap/object_class.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_class(*target_classes)



15
16
17
# File 'lib/active_ldap/object_class.rb', line 15

def add_class(*target_classes)
  replace_class(classes + target_classes)
end

- (Object) classes



41
42
43
# File 'lib/active_ldap/object_class.rb', line 41

def classes
  (get_attribute('objectClass', true) || []).dup
end


19
20
21
# File 'lib/active_ldap/object_class.rb', line 19

def ensure_recommended_classes
  add_class(self.class.recommended_classes)
end

- (Object) remove_class(*target_classes)



23
24
25
# File 'lib/active_ldap/object_class.rb', line 23

def remove_class(*target_classes)
  replace_class(classes - target_classes)
end

- (Object) replace_class(*target_classes) Also known as: classes=



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/active_ldap/object_class.rb', line 27

def replace_class(*target_classes)
  new_classes = target_classes.flatten.compact.uniq
  assert_object_classes(new_classes)
  if new_classes.sort != classes.sort
    original_attributes = must + may
    set_attribute('objectClass', new_classes)
    clear_object_class_based_cache
    new_attributes = must + may
    removed_attributes = original_attributes - new_attributes
    clear_removed_attributes_data(removed_attributes)
  end
end