chrislloyd-awesome_nested_set 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awesome_nested_set.rb +6 -2
- data/lib/awesome_nested_set/helper.rb +1 -1
- metadata +2 -2
data/lib/awesome_nested_set.rb
CHANGED
@@ -79,6 +79,8 @@ module CollectiveIdea #:nodoc:
|
|
79
79
|
|
80
80
|
before_create :set_default_left_and_right
|
81
81
|
before_destroy :prune_from_tree
|
82
|
+
|
83
|
+
belongs_to :parent, :class_name => name
|
82
84
|
|
83
85
|
# no assignment to structure fields
|
84
86
|
[left_column_name, right_column_name, parent_column_name].each do |column|
|
@@ -290,8 +292,9 @@ module CollectiveIdea #:nodoc:
|
|
290
292
|
# Returns the array of all parents and self
|
291
293
|
def self_and_ancestors
|
292
294
|
nested_set_scope.scoped :conditions => [
|
293
|
-
|
294
|
-
|
295
|
+
"#{self.class.table_name}.#{quoted_left_column_name} <= ? AND #{self.class.table_name}.#{quoted_right_column_name} >= ?", left, right
|
296
|
+
],
|
297
|
+
:order => "#{self.class.table_name}.#{quoted_left_column_name} DESC"
|
295
298
|
end
|
296
299
|
alias_method :lineage, :self_and_ancestors
|
297
300
|
|
@@ -304,6 +307,7 @@ module CollectiveIdea #:nodoc:
|
|
304
307
|
def self_and_siblings
|
305
308
|
nested_set_scope.scoped :conditions => {parent_column_name => parent_id}
|
306
309
|
end
|
310
|
+
alias_method :generation, :self_and_siblings
|
307
311
|
|
308
312
|
# Returns the array of all children of the parent, except self
|
309
313
|
def siblings
|
@@ -49,7 +49,7 @@ module CollectiveIdea #:nodoc:
|
|
49
49
|
return content if item_or_items.empty?
|
50
50
|
|
51
51
|
item_or_items.each do |i|
|
52
|
-
minor_content =
|
52
|
+
minor_content = capture(i, &block) + format_nested_set(i.children, options, &block)
|
53
53
|
content << if options[:minor][:tag]
|
54
54
|
content_tag(options[:minor][:tag], minor_content, :class => options[:minor][:class])
|
55
55
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrislloyd-awesome_nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collective Idea
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|