operation 1.3.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d6777097e8f95155f096ea3dc8b6b9e40e0462d
4
- data.tar.gz: 1479fd33c099038ce0ba1b6a151fbcaab5269849
3
+ metadata.gz: 8081d9d41eb780b0a6cfd9eab6d0c52e1943200e
4
+ data.tar.gz: c97901feb589bd338c2d4973348a75532f247f8c
5
5
  SHA512:
6
- metadata.gz: 54eac5c9b0d6dc05bac51ea7fb4d5064ebae2f464ba7c021fbf8117c88d71575d83c620b85c4e82921e754f679cebf3ad0fb0e2241f49c73082a02e2629959e8
7
- data.tar.gz: 8cee760417824fa4a6177f6827fd2d85aeb8b4af98021fe52e997f9fe10c2b9914eff9b2869062c6601a0b48a5bffcf5c823365990752a2a92375b26872b3a49
6
+ metadata.gz: 628bf4e3a84a7398fbb19662f5e1f0eddf7534bd819b8f06643ae751d76f49c42737f7bbeb57b21a5003e46ed9d9e69a3a7b82d09741117e523c438515491f4e
7
+ data.tar.gz: a14af00be7b85f775a043aec4d11cfca155aa6acf11d77ad05728bd12499d860390eb904e1cd95f2e5a7fa96b4a6e398c6e641178ce777991f34c43301f7cb4f
@@ -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
 
@@ -2,7 +2,7 @@ class Operation
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join '.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - halo