aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/acts
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-09-15 07:02:05 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-09-15 07:02:05 +0000
commit3f1acf49bd4cfa902388f000ca96c848c3666017 (patch)
treeaf197c1f4ea786e76da1f0679225572ea1953a58 /activerecord/lib/active_record/acts
parentd0c000ab9e90be4896744cb6ec107dffa573f2dd (diff)
downloadrails-3f1acf49bd4cfa902388f000ca96c848c3666017.tar.gz
rails-3f1acf49bd4cfa902388f000ca96c848c3666017.tar.bz2
rails-3f1acf49bd4cfa902388f000ca96c848c3666017.zip
Deprecation tests. Remove warnings for dynamic finders and for the foo_count ethod if it's also an attribute.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5116 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/acts')
-rw-r--r--activerecord/lib/active_record/acts/tree.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/acts/tree.rb b/activerecord/lib/active_record/acts/tree.rb
index b8654ce4e6..44432d4741 100644
--- a/activerecord/lib/active_record/acts/tree.rb
+++ b/activerecord/lib/active_record/acts/tree.rb
@@ -2,19 +2,19 @@ module ActiveRecord
module Acts #:nodoc:
module Tree #:nodoc:
def self.included(base)
- base.extend(ClassMethods)
- end
+ base.extend(ClassMethods)
+ end
- # Specify this act if you want to model a tree structure by providing a parent association and a children
+ # Specify this act if you want to model a tree structure by providing a parent association and a children
# association. This act requires that you have a foreign key column, which by default is called parent_id.
- #
+ #
# class Category < ActiveRecord::Base
# acts_as_tree :order => "name"
# end
- #
- # Example :
+ #
+ # Example:
# root
- # \_ child1
+ # \_ child1
# \_ subchild1
# \_ subchild2
#
@@ -27,7 +27,7 @@ module ActiveRecord
# root.children # => [child1]
# root.children.first.children.first # => subchild1
#
- # In addition to the parent and children associations, the following instance methods are added to the class
+ # In addition to the parent and children associations, the following instance methods are added to the class
# after specifying the act:
# * siblings : Returns all the children of the parent, excluding the current node ([ subchild2 ] when called from subchild1)
# * self_and_siblings : Returns all the children of the parent, including the current node ([ subchild1, subchild2 ] when called from subchild1)
@@ -48,7 +48,7 @@ module ActiveRecord
class_eval <<-EOV
include ActiveRecord::Acts::Tree::InstanceMethods
-
+
def self.roots
find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
end
@@ -66,13 +66,13 @@ module ActiveRecord
# subchild1.ancestors # => [child1, root]
def ancestors
node, nodes = self, []
- nodes << node = node.parent until not node.has_parent?
+ nodes << node = node.parent while node.parent
nodes
end
def root
node = self
- node = node.parent until not node.has_parent?
+ node = node.parent while node.parent
node
end
@@ -81,7 +81,7 @@ module ActiveRecord
end
def self_and_siblings
- has_parent? ? parent.children : self.class.roots
+ parent ? parent.children : self.class.roots
end
end
end