libis-workflow-mongoid 2.0.18 → 2.0.19
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dbf52eb295a357488cc482b75e3b3cf2ab4c2a8
|
4
|
+
data.tar.gz: aafeac6cd8e4a50a9864d422c2de51a7894ee8c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 092ae4d3b766b028096ad93c2b3ee85865dd433675d943338aa979e524fbb7b4da3cca8b535c782915524b747067eea995c6b39ede4dd069a28ac0668dd2289f
|
7
|
+
data.tar.gz: 28b502a5aaa9cb58f4781ccecfc174b33020ff2393b58c7ec69701aa9883ee4bf336b4f2da9d8d638946208666598bd33b63fd6716bf7ac3bcd38db1c2a61baf
|
@@ -52,11 +52,6 @@ module Libis
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
def dup
|
56
|
-
new_obj = self.class.new
|
57
|
-
new_obj.copy_attributes(self)
|
58
|
-
end
|
59
|
-
|
60
55
|
def to_hash
|
61
56
|
result = self.attributes.reject { |k, v| v.blank? || volatile_attributes.include?(k) }
|
62
57
|
result = result.to_yaml.gsub(/!ruby\/hash:BSON::Document/, '')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
3
|
module Mongoid
|
4
|
-
VERSION = '2.0.
|
4
|
+
VERSION = '2.0.19' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -13,7 +13,6 @@ module Libis
|
|
13
13
|
|
14
14
|
field :options, type: Hash, default: -> { Hash.new }
|
15
15
|
field :properties, type: Hash, default: -> { Hash.new }
|
16
|
-
field :summary, type: Hash, default: -> { Hash.new }
|
17
16
|
field :status_log, type: Array, default: -> { Array.new }
|
18
17
|
|
19
18
|
index({_id: 1, _type: 1}, {unique: true, name: 'by_id'})
|
@@ -26,11 +25,20 @@ module Libis
|
|
26
25
|
index({parent_id: 1, parent_type: 1, c_at: 1}, {name: 'by_parent'})
|
27
26
|
|
28
27
|
def add_item(item)
|
28
|
+
raise Libis::WorkflowError, 'Trying to add item already linked to another item' unless item.parent.nil?
|
29
|
+
super(item)
|
30
|
+
end
|
31
|
+
|
32
|
+
def move_item(item)
|
33
|
+
new_item = item.dup
|
34
|
+
yield new_item, item if block_given?
|
35
|
+
new_item.parent = nil
|
36
|
+
item.items.each { |i| new_item.move_item(i) }
|
37
|
+
self.add_item(new_item)
|
29
38
|
if item.parent
|
30
|
-
item.parent.delete(item)
|
31
|
-
item.parent.save!
|
39
|
+
item.parent.items.delete(item)
|
32
40
|
end
|
33
|
-
|
41
|
+
new_item
|
34
42
|
end
|
35
43
|
|
36
44
|
def get_items
|
data/spec/workflow_spec.rb
CHANGED