Class Index [+]

Quicksearch

ActiveLdap::Acts::Tree

Public Class Methods

included(base) click to toggle 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

ancestors() click to toggle source

Returns list of ancestors, starting from parent until root.

  subchild1.ancestors # => [child1, root]
    # 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
parent() click to toggle 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
parent=(entry) click to toggle 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
root() click to toggle source

Returns the root node of the tree.

    # 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
self_and_siblings() click to toggle source

Returns all siblings and a reference to the current node.

  subchild1.self_and_siblings # => [subchild1, subchild2]
    # File lib/active_ldap/acts/tree.rb, line 45
45:       def self_and_siblings
46:         parent ? parent.children : [self]
47:       end
siblings() click to toggle source

Returns all siblings of the current node.

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.