glebtv-mongoid_nested_set 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 953791c3a0f6c4ac721064a644618e1483cf0e84
4
- data.tar.gz: 6b4bd39932a7b028bdf028d28224c6eb3f9b1cc5
3
+ metadata.gz: a07ed6d681a31e48faa1d490812bf2d556505368
4
+ data.tar.gz: 5cea8896930423eb28967620a12d1e21c4892553
5
5
  SHA512:
6
- metadata.gz: 574d7024162ace5b17a05231ab3b9eb1cc2277cfd1b46882438e41582230cf19a07d9feaf9d43a4ac932a1015d96edbc79c81e9115fcbaf5bd2bd633fbed5e8c
7
- data.tar.gz: 057192f6c849596541d59e1f124d8b292b4e07bb57b4b7efa9564351d9fafb9564ea4d7e1fb49ef926e264335e8802f5a8331bdf84363f3dca5e51cc1dc0713e
6
+ metadata.gz: 85bac01380f2f967f260ae41bc349cbbe2a97c1efdc5a7f0dbeb503036b339a73377c31c2023aa5ec6d13b0085b6260062367933253db0e9881a16f597a43bf8
7
+ data.tar.gz: 25f4ad3e4fd16afbcd5a849b86af10a7e105966ccabfac5ff1d2c00c25992ee5dc64d9b33010e693468d424789356d20cfb9c1361b7b056dd82d60ab11a20213
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ mongoid_nested_set
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p195
@@ -53,9 +53,13 @@ module Mongoid::Acts::NestedSet
53
53
 
54
54
  attr_accessor :skip_before_destroy
55
55
 
56
- #if accessible_attributes.blank?
57
- # attr_protected left_field_name.intern, right_field_name.intern
58
- #end
56
+ # Rails 4 no longer uses "attr_protected" and "attr_accessible" for
57
+ # mass assignment control by default, but this methods can be restored
58
+ # by installing 'protected_attributes' gem. So here we just check
59
+ # accessible_attributes method presence
60
+ if respond_to?(:accessible_attributes) && accessible_attributes.blank?
61
+ attr_protected left_field_name.intern, right_field_name.intern
62
+ end
59
63
 
60
64
  define_callbacks :move, :terminator => "result == false"
61
65
 
@@ -153,7 +153,7 @@ module Mongoid::Acts::NestedSet
153
153
  ).update_all("$inc" => { right_field_name => -width })
154
154
  end
155
155
 
156
- self.set(parent_field_name, new_parent)
156
+ self.mongoid_set(parent_field_name, new_parent)
157
157
  self.reload_nested_set
158
158
  self.update_self_and_descendants_depth
159
159
 
@@ -188,7 +188,7 @@ module Mongoid::Acts::NestedSet
188
188
  def update_self_and_descendants_depth
189
189
  if depth?
190
190
  scope_class.each_with_level(self_and_descendants) do |node, level|
191
- node.with(:safe => true).set(:depth, level) unless node.depth == level
191
+ node.with(:safe => true).mongoid_set(:depth, level) unless node.depth == level
192
192
  end
193
193
  self.reload
194
194
  end
@@ -226,5 +226,15 @@ module Mongoid::Acts::NestedSet
226
226
  self.skip_before_destroy = true
227
227
  end
228
228
 
229
+ # Compatibility wrapper for mongoid set method, should works with 3.x.x and
230
+ # 4.x.x versions
231
+ def mongoid_set(field, value)
232
+ if method(:set).arity == 1
233
+ set({field => value})
234
+ else
235
+ set(field, value)
236
+ end
237
+ end
238
+
229
239
  end
230
240
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidNestedSet
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  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.3.0
4
+ version: 0.4.0
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-05-03 00:00:00.000000000 Z
12
+ date: 2013-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -91,6 +91,8 @@ files:
91
91
  - .document
92
92
  - .gitignore
93
93
  - .rspec
94
+ - .ruby-gemset
95
+ - .ruby-version
94
96
  - Gemfile
95
97
  - LICENSE.txt
96
98
  - README.markdown
@@ -144,4 +146,16 @@ rubygems_version: 2.0.3
144
146
  signing_key:
145
147
  specification_version: 4
146
148
  summary: Nested set based tree implementation for Mongoid
147
- test_files: []
149
+ test_files:
150
+ - spec/matchers/nestedset_pos.rb
151
+ - spec/models/circle_node.rb
152
+ - spec/models/node.rb
153
+ - spec/models/node_without_nested_set.rb
154
+ - spec/models/numbering_node.rb
155
+ - spec/models/renamed_fields.rb
156
+ - spec/models/shape_node.rb
157
+ - spec/models/square_node.rb
158
+ - spec/models/test_document.rb
159
+ - spec/models/unscoped_node.rb
160
+ - spec/mongoid_nested_set_spec.rb
161
+ - spec/spec_helper.rb