acts_as_sane_tree 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc
CHANGED
@@ -34,7 +34,7 @@ module ActsAsSaneTree
|
|
34
34
|
#
|
35
35
|
# * <tt>nodes_within?(src, chk)</tt> - Returns true if chk contains any nodes found within src and all ancestors of nodes within src
|
36
36
|
# * <tt>nodes_within(src, chk)</tt> - Returns any matching nodes from chk found within src and all ancestors within src
|
37
|
-
# * <tt>
|
37
|
+
# * <tt>nodes_and_descendants(*args)</tt> - Returns all nodes and descendants for given IDs or records. Accepts multiple IDs and records. Valid options:
|
38
38
|
# * :raw - No Hash nesting
|
39
39
|
# * :no_self - Will not return given nodes in result set
|
40
40
|
# * {:depth => n} - Will set maximum depth to query
|
@@ -55,7 +55,7 @@ module ActsAsSaneTree
|
|
55
55
|
parent_id.nil?
|
56
56
|
end
|
57
57
|
|
58
|
-
# Returns all
|
58
|
+
# Returns all descendants of the current node. Each level
|
59
59
|
# is within its own hash, so for a structure like:
|
60
60
|
# root
|
61
61
|
# \_ child1
|
@@ -71,13 +71,14 @@ module ActsAsSaneTree
|
|
71
71
|
#
|
72
72
|
# This method will accept two parameters.
|
73
73
|
# * :raw -> Result is scope that can more finders can be chained against with additional 'level' attribute
|
74
|
-
# * {:depth => n} -> Will only search for
|
74
|
+
# * {:depth => n} -> Will only search for descendants to the given depth of n
|
75
75
|
# NOTE: You can restrict results by depth on the scope returned, but better performance will be
|
76
76
|
# gained by specifying it within the args so it will be applied during the recursion, not after.
|
77
|
-
def
|
77
|
+
def descendants(*args)
|
78
78
|
args.delete_if{|x| !x.is_a?(Hash) && x != :raw}
|
79
|
-
self.class.configuration[:class].
|
79
|
+
self.class.configuration[:class].nodes_and_descendants(:no_self, self, *args)
|
80
80
|
end
|
81
|
+
alias_method :descendents, :descendants
|
81
82
|
|
82
83
|
# Returns the depth of the current node. 0 depth represents the root of the tree
|
83
84
|
def depth
|
@@ -78,13 +78,13 @@ module ActsAsSaneTree
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# args:: ActiveRecord models or IDs - Symbols: :raw, :no_self - Hash: {:to_depth => n, :at_depth => n}
|
81
|
-
# Returns provided nodes plus all
|
81
|
+
# Returns provided nodes plus all descendants of provided nodes in nested Hash where keys are nodes and values are children
|
82
82
|
# :raw:: return value will be flat array
|
83
83
|
# :no_self:: Do not include provided nodes in result
|
84
84
|
# Hash:
|
85
85
|
# :to_depth:: Only retrieve values to given depth
|
86
86
|
# :at_depth:: Only retrieve values from given depth
|
87
|
-
def
|
87
|
+
def nodes_and_descendants(*args)
|
88
88
|
raw = args.delete(:raw)
|
89
89
|
no_self = args.delete(:no_self)
|
90
90
|
at_depth = nil
|
@@ -152,6 +152,7 @@ module ActsAsSaneTree
|
|
152
152
|
q
|
153
153
|
end
|
154
154
|
end
|
155
|
+
alias_method :nodes_and_descendents, :nodes_and_descendants
|
155
156
|
|
156
157
|
end
|
157
158
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_sane_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 2
|
10
|
+
version: 2.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Roberts
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-15 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements: []
|
82
82
|
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.6.2
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
87
|
summary: Sane tree builder for ActiveRecord and Postgresql
|