dm-is-awesome_set 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dm-is-awesome_set.gemspec +2 -2
- data/lib/dm-is-awesome_set.rb +16 -12
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.1
|
data/dm-is-awesome_set.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-is-awesome_set}
|
8
|
-
s.version = "0.11.
|
8
|
+
s.version = "0.11.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremy Nicoll", "David Haslem", "Martin Gamsjaeger (snusnu)"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-19}
|
13
13
|
s.description = %q{A library that lets any datamapper model act like a nested set}
|
14
14
|
s.email = %q{jnicoll@gnexp.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/dm-is-awesome_set.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
['dm-core', 'dm-adjust', 'dm-aggregates', 'dm-validations'].each do |dm_var|
|
2
|
+
require dm_var
|
3
|
+
end
|
4
|
+
|
1
5
|
module DataMapper
|
2
6
|
module Is
|
3
7
|
##
|
@@ -302,9 +306,9 @@ module DataMapper
|
|
302
306
|
|
303
307
|
def same_scope?(obj)
|
304
308
|
case obj
|
305
|
-
when get_class
|
306
|
-
when Hash
|
307
|
-
when nil
|
309
|
+
when get_class then scope_hash == obj.send(:scope_hash)
|
310
|
+
when Hash then scope_hash == obj
|
311
|
+
when nil then true
|
308
312
|
end
|
309
313
|
end
|
310
314
|
|
@@ -327,12 +331,12 @@ module DataMapper
|
|
327
331
|
|
328
332
|
# Convenience methods
|
329
333
|
ret_value = case action
|
330
|
-
when :higher
|
331
|
-
when :highest
|
332
|
-
when :lower
|
333
|
-
when :lowest
|
334
|
-
when :indent
|
335
|
-
when :outdent
|
334
|
+
when :higher then previous_sibling ? move_without_saving(:above => previous_sibling) : false
|
335
|
+
when :highest then move_without_saving(:to => parent ? (parent.lft + 1) : 1)
|
336
|
+
when :lower then next_sibling ? move_without_saving(:below => next_sibling) : false
|
337
|
+
when :lowest then parent ? move_without_saving(:to => parent.rgt - 1) : move_without_saving(:root)
|
338
|
+
when :indent then previous_sibling ? move_without_saving(:into => previous_sibling) : false
|
339
|
+
when :outdent then parent ? move_without_saving(:below => parent) : false
|
336
340
|
else :no_action
|
337
341
|
end
|
338
342
|
return ret_value unless ret_value == :no_action
|
@@ -348,9 +352,9 @@ module DataMapper
|
|
348
352
|
when :root
|
349
353
|
new_scope = obj ? extract_scope(obj) : scope_hash
|
350
354
|
max = (get_class.max(:rgt, new_scope) || 0) + 1
|
351
|
-
when :into
|
352
|
-
when :above
|
353
|
-
when :below
|
355
|
+
when :into then [obj.rgt, obj.rgt - 1, obj]
|
356
|
+
when :above then [obj.lft, obj.lft - 1, obj.parent]
|
357
|
+
when :below then [obj.rgt + 1, obj.rgt, obj.parent]
|
354
358
|
when :to
|
355
359
|
pos = obj.to_i
|
356
360
|
p_obj = get_class.first(scope_hash.merge(:lft.lt => pos, :rgt.gt => pos, :order => [:lft.desc]))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-is-awesome_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Nicoll
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-02-
|
14
|
+
date: 2010-02-19 00:00:00 -05:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|