Module ActiveLdap::Acts::Tree
In: lib/active_ldap/acts/tree.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations 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 Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb 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 Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_44_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)
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]