Module ActiveLdap::Acts::Tree
In: lib/active_ldap/acts/tree.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

Classes and Modules

Module ActiveLdap::Acts::Tree::ClassMethods

Public Class methods

[Source]

    # File lib/active_ldap/acts/tree.rb, line 4
 4:       def self.included(base)
 5:         base.class_eval do
 6:           extend(ClassMethods)
 7:           association_accessor(:children) do |target|
 8:             Association::Children.new(target, {})
 9:           end
10:         end
11:       end

Public Instance methods

Returns list of ancestors, starting from parent until root.

  subchild1.ancestors # => [child1, root]

[Source]

    # File lib/active_ldap/acts/tree.rb, line 22
22:       def ancestors
23:         node, nodes = self, []
24:         nodes << node = node.parent while node.parent
25:         nodes
26:       end

[Source]

    # File lib/active_ldap/acts/tree.rb, line 49
49:       def parent
50:         if base == self.class.base
51:           nil
52:         else
53:           find(:first, :base => base, :scope => :base)
54:         end
55:       end

[Source]

    # File lib/active_ldap/acts/tree.rb, line 57
57:       def parent=(entry)
58:         if entry.is_a?(String) or entry.is_a?(DN)
59:           base = entry
60:         elsif entry.respond_to?(:dn)
61:           base = entry.dn
62:           if entry.respond_to?(:clear_association_cache)
63:             entry.clear_association_cache
64:           end
65:         else
66:           message = _("parent must be an entry or parent DN: %s") % entry.inspect
67:           raise ArgumentError, message
68:         end
69:         destroy unless new_entry?
70:         self.dn = "#{dn_attribute}=#{id},#{base}"
71:         save
72:       end

Returns the root node of the tree.

[Source]

    # File lib/active_ldap/acts/tree.rb, line 29
29:       def root
30:         node = self
31:         node = node.parent while node.parent
32:         node
33:       end

Returns all siblings and a reference to the current node.

  subchild1.self_and_siblings # => [subchild1, subchild2]

[Source]

    # File lib/active_ldap/acts/tree.rb, line 45
45:       def self_and_siblings
46:         parent ? parent.children : [self]
47:       end

Returns all siblings of the current node.

  subchild1.siblings # => [subchild2]

[Source]

    # File lib/active_ldap/acts/tree.rb, line 38
38:       def siblings
39:         self_and_siblings - [self]
40:       end

[Validate]