diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-03-27 14:04:06 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-03-27 14:04:06 +0000 |
commit | 2a305949d756c054cee349c1ef3b39c6cf1496f8 (patch) | |
tree | 6de4aa3106b92e128a6b62dae9938b73a1f7ed03 /activerecord/lib/active_record/acts/tree.rb | |
parent | 4b78a2a245cb69e958e3d62d4c0e6fcab2eb3e76 (diff) | |
download | rails-2a305949d756c054cee349c1ef3b39c6cf1496f8.tar.gz rails-2a305949d756c054cee349c1ef3b39c6cf1496f8.tar.bz2 rails-2a305949d756c054cee349c1ef3b39c6cf1496f8.zip |
documentation project patches, closes #7342, #7319, #7316, #7190 [jeremymcanally]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6470 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/acts/tree.rb')
-rw-r--r-- | activerecord/lib/active_record/acts/tree.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/acts/tree.rb b/activerecord/lib/active_record/acts/tree.rb index 44432d4741..b92587e521 100644 --- a/activerecord/lib/active_record/acts/tree.rb +++ b/activerecord/lib/active_record/acts/tree.rb @@ -70,16 +70,23 @@ module ActiveRecord nodes end + # Returns the root node of the tree. def root node = self node = node.parent while node.parent node end + # Returns all siblings of the current node. + # + # subchild1.siblings # => [subchild2] def siblings self_and_siblings - [self] end + # Returns all siblings and a reference to the current node. + # + # subchild1.self_and_siblings # => [subchild1, subchild2] def self_and_siblings parent ? parent.children : self.class.roots end |