noodall-core 0.3.1 → 0.3.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/lib/noodall/node.rb CHANGED
@@ -76,29 +76,29 @@ module Noodall
76
76
  end
77
77
 
78
78
  def last?
79
- position == self.class.count(:_id => {"$ne" => self._id}, parent_id_field => self[parent_id_field])
79
+ position == search_class.count(:_id => {"$ne" => self._id}, parent_id_field => self[parent_id_field])
80
80
  end
81
81
  def move_lower
82
- sibling = self.class.first(:position => {"$gt" => self.position}, parent_id_field => self[parent_id_field], :order => 'position ASC')
82
+ sibling = search_class.first(:position => {"$gt" => self.position}, parent_id_field => self[parent_id_field], :order => 'position ASC')
83
83
 
84
84
  tmp = sibling.position
85
85
  sibling.position = self.position
86
86
  self.position = tmp
87
87
 
88
- self.class.collection.update({:_id => self._id}, self.to_mongo)
89
- self.class.collection.update({:_id => sibling._id}, sibling.to_mongo)
88
+ search_class.collection.update({:_id => self._id}, self.to_mongo)
89
+ search_class.collection.update({:_id => sibling._id}, sibling.to_mongo)
90
90
 
91
91
  global_updated!
92
92
  end
93
93
  def move_higher
94
- sibling = self.class.first(:position => {"$lt" => self.position}, parent_id_field => self[parent_id_field], :order => 'position DESC')
94
+ sibling = search_class.first(:position => {"$lt" => self.position}, parent_id_field => self[parent_id_field], :order => 'position DESC')
95
95
 
96
96
  tmp = sibling.position
97
97
  sibling.position = self.position
98
98
  self.position = tmp
99
99
 
100
- self.class.collection.update({:_id => self._id}, self.to_mongo)
101
- self.class.collection.update({:_id => sibling._id}, sibling.to_mongo)
100
+ search_class.collection.update({:_id => self._id}, self.to_mongo)
101
+ search_class.collection.update({:_id => sibling._id}, sibling.to_mongo)
102
102
 
103
103
  global_updated!
104
104
  end
@@ -149,16 +149,16 @@ module Noodall
149
149
  end
150
150
 
151
151
  def siblings
152
- self.class.where(:_id => {:$ne => self._id}, parent_id_field => self[parent_id_field]).order(tree_order)
152
+ search_class.where(:_id => {:$ne => self._id}, parent_id_field => self[parent_id_field]).order(tree_order)
153
153
  end
154
154
 
155
155
  def self_and_siblings
156
- self.class.where(parent_id_field => self[parent_id_field]).order(tree_order)
156
+ search_class.where(parent_id_field => self[parent_id_field]).order(tree_order)
157
157
 
158
158
  end
159
159
 
160
160
  def children
161
- self.class.where(parent_id_field => self._id).order(tree_order)
161
+ search_class.where(parent_id_field => self._id).order(tree_order)
162
162
  end
163
163
 
164
164
  private
@@ -225,11 +225,11 @@ module Noodall
225
225
  after_save :order_siblings
226
226
  def order_siblings
227
227
  if position_changed?
228
- self.class.collection.update({:_id => {"$ne" => self._id}, :position => {"$gte" => self.position}, parent_id_field => self[parent_id_field]}, { "$inc" => { :position => 1 }}, { :multi => true })
228
+ search_class.collection.update({:_id => {"$ne" => self._id}, :position => {"$gte" => self.position}, parent_id_field => self[parent_id_field]}, { "$inc" => { :position => 1 }}, { :multi => true })
229
229
  self_and_siblings.each_with_index do |sibling, index|
230
230
  unless sibling.position == index
231
231
  sibling.position = index
232
- self.class.collection.save(sibling.to_mongo, :safe => true)
232
+ search_class.collection.save(sibling.to_mongo, :safe => true)
233
233
  end
234
234
  end
235
235
  end
data/noodall-core.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{noodall-core}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Steve England"]
data/spec/node_spec.rb CHANGED
@@ -60,7 +60,11 @@ describe Noodall::Node do
60
60
 
61
61
  describe "within a tree" do
62
62
  before(:each) do
63
- @root = Page.create!(:title => "Root")
63
+ class LandingPage < Noodall::Node
64
+ root_template!
65
+ end
66
+
67
+ @root = LandingPage.create!(:title => "Root")
64
68
 
65
69
  @child = Page.create!(:title => "Ickle Kid", :parent => @root)
66
70
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve England