oakridgelanl-materialized-path 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.
Files changed (3) hide show
  1. data/TODO +11 -0
  2. data/lib/acts_as_materialized_path.rb +28 -16
  3. metadata +6 -3
data/TODO ADDED
@@ -0,0 +1,11 @@
1
+ -*- text -*-
2
+
3
+ Include tests from plugin version in gem.
4
+
5
+ Include examples from plugin version in gem.
6
+
7
+ Add data exclusion functionality for methods that only traverse the
8
+ tree(s) in some way (i.e. don't fetch anything beyond id and path
9
+ columns for these methods). Possibly allow for this functionality on
10
+ most methods.
11
+
@@ -244,27 +244,39 @@ module ActiveRecord #:nodoc:
244
244
  #
245
245
  def save
246
246
  if new_record? && !the_path
247
- self.class.transaction do
248
- basepath = ''
249
- if mp_parent_id_for_save.to_i > 0
250
- relation = mp_parent_id_for_save
251
- sibling = false
252
- elsif mp_sibling_id_for_save.to_i > 0
253
- relation = mp_sibling_id_for_save
254
- sibling = true
255
- end
256
- basepath =
257
- self.class.find(relation).the_path(sibling) if relation
258
-
259
- nextval = nextvalue(basepath)
260
- set_path(basepath+self.class.num2path_string(nextval)+mp_delimiter)
261
- super
262
- end
247
+ handle_new_record_code
248
+ super
249
+ else
250
+ super
251
+ end
252
+ end
253
+
254
+ def save!
255
+ if new_record? && !the_path
256
+ handle_new_record_code
257
+ super
263
258
  else
264
259
  super
265
260
  end
266
261
  end
267
262
 
263
+ def handle_new_record_code
264
+ self.class.transaction do
265
+ basepath = ''
266
+ if mp_parent_id_for_save.to_i > 0
267
+ relation = mp_parent_id_for_save
268
+ sibling = false
269
+ elsif mp_sibling_id_for_save.to_i > 0
270
+ relation = mp_sibling_id_for_save
271
+ sibling = true
272
+ end
273
+ basepath =
274
+ self.class.find(relation).the_path(sibling) if relation
275
+
276
+ nextval = nextvalue(basepath)
277
+ set_path(basepath+self.class.num2path_string(nextval)+mp_delimiter)
278
+ end
279
+ end
268
280
  #
269
281
 
270
282
  #
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oakridgelanl-materialized-path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antony Donovan
8
+ - Jonathan Barket
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2008-05-15 00:00:00 -07:00
13
+ date: 2008-07-30 00:00:00 -07:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
@@ -29,9 +30,11 @@ extensions: []
29
30
 
30
31
  extra_rdoc_files:
31
32
  - README
33
+ - TODO
32
34
  files:
33
35
  - README
34
36
  - lib/acts_as_materialized_path.rb
37
+ - TODO
35
38
  has_rdoc: true
36
39
  homepage:
37
40
  post_install_message:
@@ -55,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
58
  requirements: []
56
59
 
57
60
  rubyforge_project:
58
- rubygems_version: 1.0.1
61
+ rubygems_version: 1.2.0
59
62
  signing_key:
60
63
  specification_version: 2
61
64
  summary: An ActsAs mixin implementing a set of trees (nested set) for ActiveRecord