mongoid_tree 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mongoid_tree.rb +9 -4
- data/mongoid_tree.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/mongoid_tree.rb
CHANGED
@@ -144,13 +144,18 @@ module Mongoid
|
|
144
144
|
end
|
145
145
|
parent.children << new_child
|
146
146
|
end
|
147
|
+
|
148
|
+
def unhinge
|
149
|
+
# unhinge - I was getting a nil on another implementation, so this is a bit longer but works
|
150
|
+
child_ids_array = parent.child_ids.clone
|
151
|
+
child_ids_array.delete(id)
|
152
|
+
parent.update_attributes(:child_ids => child_ids_array )
|
153
|
+
self.update_attributes(:parent_ids => [], :position => nil )
|
154
|
+
end
|
147
155
|
|
148
156
|
def move_to(target_node)
|
149
157
|
# unhinge - I was getting a nil on another implementation, so this is a bit longer but works
|
150
|
-
|
151
|
-
child_ids_array.delete(id)
|
152
|
-
parent.update_attributes(:child_ids => child_ids_array )
|
153
|
-
self.update_attributes(:parent_ids => [], :position => nil )
|
158
|
+
unhinge
|
154
159
|
# and append
|
155
160
|
target_node.children << self
|
156
161
|
# recurse through subtree
|
data/mongoid_tree.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoid_tree}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rainer Kuhn"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-25}
|
13
13
|
s.description = %q{Fully featured tree implementation for Mongoid using materialized paths and relative associations. Featuring Depth and Breadth first search.}
|
14
14
|
s.email = %q{rkuhn@littleweblab.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 6
|
9
|
+
version: 0.3.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Rainer Kuhn
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-25 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|