operation 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/operation/deferrable.rb +21 -0
- data/lib/operation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8081d9d41eb780b0a6cfd9eab6d0c52e1943200e
|
4
|
+
data.tar.gz: c97901feb589bd338c2d4973348a75532f247f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628bf4e3a84a7398fbb19662f5e1f0eddf7534bd819b8f06643ae751d76f49c42737f7bbeb57b21a5003e46ed9d9e69a3a7b82d09741117e523c438515491f4e
|
7
|
+
data.tar.gz: a14af00be7b85f775a043aec4d11cfca155aa6acf11d77ad05728bd12499d860390eb904e1cd95f2e5a7fa96b4a6e398c6e641178ce777991f34c43301f7cb4f
|
data/lib/operation/deferrable.rb
CHANGED
@@ -32,6 +32,17 @@ class Operation
|
|
32
32
|
self
|
33
33
|
end
|
34
34
|
|
35
|
+
def on_finish(&block)
|
36
|
+
return unless block
|
37
|
+
|
38
|
+
if succeeded? || failed?
|
39
|
+
block.call(*arguments)
|
40
|
+
else
|
41
|
+
finishables.unshift block
|
42
|
+
end
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
35
46
|
# Public State Getters
|
36
47
|
|
37
48
|
def status
|
@@ -91,12 +102,18 @@ class Operation
|
|
91
102
|
while callback = successables.pop
|
92
103
|
callback.call(*arguments)
|
93
104
|
end
|
105
|
+
while callback = finishables.pop
|
106
|
+
callback.call(*arguments)
|
107
|
+
end
|
94
108
|
failables.clear if !failables.empty?
|
95
109
|
|
96
110
|
elsif failed? && !failables.empty?
|
97
111
|
while callback = failables.pop
|
98
112
|
callback.call(*arguments)
|
99
113
|
end
|
114
|
+
while callback = finishables.pop
|
115
|
+
callback.call(*arguments)
|
116
|
+
end
|
100
117
|
successables.clear if !failables.empty?
|
101
118
|
end
|
102
119
|
end
|
@@ -115,6 +132,10 @@ class Operation
|
|
115
132
|
@progressables ||= []
|
116
133
|
end
|
117
134
|
|
135
|
+
def finishables
|
136
|
+
@finishables ||= []
|
137
|
+
end
|
138
|
+
|
118
139
|
end
|
119
140
|
end
|
120
141
|
|
data/lib/operation/version.rb
CHANGED