glebtv-mongoid_nested_set 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/mongoid_nested_set/update.rb +14 -4
- data/lib/mongoid_nested_set/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06f74b01b36e9f6e96dbc59aacdc68b68069182d
|
4
|
+
data.tar.gz: 7acff99227594a6601f8141a99bf60408987d16d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cb2a314591b0f6b80c1c6caa626c6b249980c2a6c91a8fef10921abc930f91d8370aa54494ac7b1f4f7b18d686ee5a963f934f8ac8a2747ca8d988c3cf59a9d
|
7
|
+
data.tar.gz: 36eca30d0546e7f262cc103731500a528c341ff2e5a9ae00ddd86f3880dde97e6886155295b8c16d429c0e8f64ff6045ae86b78ac8173c58c8a909016670f07e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0-
|
1
|
+
2.0.0-p247
|
@@ -214,13 +214,15 @@ module Mongoid::Acts::NestedSet
|
|
214
214
|
# update lefts and rights for remaining nodes
|
215
215
|
diff = right - left + 1
|
216
216
|
|
217
|
-
scope_class.with(:safe => true).where(
|
217
|
+
c = scope_class.with(:safe => true).where(
|
218
218
|
nested_set_scope.where(left_field_name.to_sym.gt => right).selector
|
219
|
-
)
|
219
|
+
)
|
220
|
+
mongoid_inc(c, left_field_name, -diff)
|
220
221
|
|
221
|
-
scope_class.with(:safe => true).where(
|
222
|
+
c = scope_class.with(:safe => true).where(
|
222
223
|
nested_set_scope.where(right_field_name.to_sym.gt => right).selector
|
223
|
-
)
|
224
|
+
)
|
225
|
+
mongoid_inc(c, right_field_name, -diff)
|
224
226
|
|
225
227
|
# Don't allow multiple calls to destroy to corrupt the set
|
226
228
|
self.skip_before_destroy = true
|
@@ -236,5 +238,13 @@ module Mongoid::Acts::NestedSet
|
|
236
238
|
end
|
237
239
|
end
|
238
240
|
|
241
|
+
def mongoid_inc(criteria, field, value)
|
242
|
+
if Mongoid::VERSION.to_i < 4
|
243
|
+
criteria.inc(field, value)
|
244
|
+
else
|
245
|
+
criteria.inc({field => value})
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
239
249
|
end
|
240
250
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glebtv-mongoid_nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GlebTV
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project: mongoid_nested_set
|
145
|
-
rubygems_version: 2.0.
|
145
|
+
rubygems_version: 2.0.6
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Nested set based tree implementation for Mongoid
|