mongoid_order 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -16,7 +16,7 @@ To install mongoid_order, simply add it to your Gemfile:
16
16
 
17
17
  gem 'mongoid_order'
18
18
 
19
- In order to get the latest development version of mongoid-tree:
19
+ In order to get the latest development version of mongoid_order:
20
20
 
21
21
  gem 'mongoid_order', :git => 'https://github.com/arkxu/mongoid_order.git'
22
22
 
data/lib/mongoid_order.rb CHANGED
@@ -32,26 +32,26 @@ module Mongoid
32
32
  # Returns siblings below the current document.
33
33
  # Siblings with a position greater than this documents's position.
34
34
  def lower_siblings
35
- self.class.all.where(:position.gt => self.position)
35
+ self.class.where(:position.gt => self.position)
36
36
  end
37
37
 
38
38
  ##
39
39
  # Returns siblings above the current document.
40
40
  # Siblings with a position lower than this documents's position.
41
41
  def higher_siblings
42
- self.class.all.where(:position.lt => self.position)
42
+ self.class.where(:position.lt => self.position)
43
43
  end
44
44
 
45
45
  ##
46
46
  # Returns the lowest sibling (could be self)
47
47
  def last_sibling_in_list
48
- self.class.all.asc(:position).last
48
+ self.class.asc(:position).last
49
49
  end
50
50
 
51
51
  ##
52
52
  # Returns the highest sibling (could be self)
53
53
  def first_sibling_in_list
54
- self.class.all.asc(:position).first
54
+ self.class.asc(:position).first
55
55
  end
56
56
 
57
57
  ##
@@ -84,7 +84,7 @@ module Mongoid
84
84
  # Move this node one position up
85
85
  def move_up
86
86
  return if at_top?
87
- self.class.all.where(:position => self.position - 1).first.inc(:position, 1)
87
+ self.class.where(:position => self.position - 1).first.inc(:position, 1)
88
88
  inc(:position, -1)
89
89
  end
90
90
 
@@ -92,7 +92,7 @@ module Mongoid
92
92
  # Move this node one position down
93
93
  def move_down
94
94
  return if at_bottom?
95
- self.class.all.where(:position => self.position + 1).first.inc(:position, -1)
95
+ self.class.where(:position => self.position + 1).first.inc(:position, -1)
96
96
  inc(:position, 1)
97
97
  end
98
98
 
@@ -146,7 +146,7 @@ module Mongoid
146
146
  if self.class.all.empty? || self.class.all.collect(&:position).compact.empty?
147
147
  self.position = 0
148
148
  else
149
- self.position = self.class.all.max(:position) + 1
149
+ self.position = self.class.max(:position) + 1
150
150
  end
151
151
  end
152
152
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "mongoid_order"
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Ark Xu"]
8
8
  s.email = ["ark.work@gmail.com"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_order
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ark Xu