dirty_pipeline 0.6.2 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 398ceefff1e7e57f7ad43cb979c1ef0f7b4430bbc017e92396a8e66565d86be9
4
- data.tar.gz: 82b81adf9a24970e3dfc3b51b76a833115c535b356dd41d3c84b619cd36308df
3
+ metadata.gz: 6871bd0a1aaa3608ff81749b66157171ea26d1881774fa8ba221cd0ce3f88b4b
4
+ data.tar.gz: 81c5a14ab2bb2f4437175171e7afe65dbe75006d7f4a48bf2fd8fc3b2e947721
5
5
  SHA512:
6
- metadata.gz: 2ea3ac89978a5ba280a6729623e25e14b48ac2f0e858ee92c41fafb6570f18dea35e43824b480db7d62dc9d6f13cd58adc477265f1ae24d4e67dbe98a6d309c5
7
- data.tar.gz: 9e3de820fcb941446252427f2daf864c5d17d7f82f7b16d87f1d4aa5e0227b27e8924871539b251264c0dadf5ce7b3c71f9c70fdad9023a45b27ad176c2cb637
6
+ metadata.gz: f896cc7c517490b1f0a942f17f7df16a0e27ff67bb87f64e46dd0665c3b6444aebd58e0ca7d0d882af5ab7708f411b1caf1904ab229693b5785690ab97779aa1
7
+ data.tar.gz: 5ff0a159e5b00963a1685ff94c425090d4f8aecaf855fff6e588e85f40e6aadbb199b41be26adcab512027727839ad968c3355a9302dd6709d8b75b5f34cc1da
@@ -164,7 +164,6 @@ module DirtyPipeline
164
164
  end
165
165
 
166
166
  def Failure(event, cause, type:)
167
- railway.switch_to(:undo)
168
167
  event.failure!
169
168
  @status = Status.failure(cause, tag: type)
170
169
  end
@@ -1,45 +1,48 @@
1
1
  module DirtyPipeline
2
2
  class Transition
3
- def Error(error)
3
+ def Failure(error)
4
+ railway.switch_to(:undo)
4
5
  throw :fail_transition, error
5
6
  end
6
7
 
7
8
  def Success(changes = nil)
9
+ case railway.active
10
+ when "call"
11
+ railway.switch_to(:finalize) if respond_to?(:finalize)
12
+ when "finalize"
13
+ railway.switch_to(:call)
14
+ end
8
15
  throw :success, changes.to_h
9
16
  end
10
-
11
17
  def self.finalize(*args, **kwargs)
12
18
  event, pipeline, *args = args
13
- instance = new(event, *args, **kwargs)
19
+ instance = new(event, pipeline.railway, *args, **kwargs)
14
20
  return unless instance.respond_to?(:finalize)
15
- pipeline.railway.switch_to(:call)
16
21
  instance.finalize(pipeline.subject)
17
22
  end
18
23
 
19
24
  def self.undo(*args, **kwargs)
20
25
  event, pipeline, *args = args
21
- instance = new(event, *args, **kwargs)
26
+ instance = new(event, pipeline.railway, *args, **kwargs)
22
27
  return unless instance.respond_to?(:undo)
23
28
  instance.undo(pipeline.subject)
24
29
  end
25
30
 
26
31
  def self.call(*args, **kwargs)
27
32
  event, pipeline, *args = args
28
- instance = new(event, *args, **kwargs)
29
- pipeline.railway[:undo] << event if instance.respond_to?(:undo)
30
- if instance.respond_to?(:finalize)
31
- pipeline.railway[:finalize] << event
32
- pipeline.railway.switch_to(:finalize)
33
- end
34
- new(event, *args, **kwargs).call(pipeline.subject)
33
+ instance = new(event, pipeline.railway, *args, **kwargs)
34
+ pipeline.railway[:undo] << event
35
+ pipeline.railway[:finalize] << event
36
+ instance.call(pipeline.subject)
35
37
  end
36
38
 
37
- attr_reader :event
38
- def initialize(event, *, **)
39
+ attr_reader :event, :railway
40
+ def initialize(event, railway, *, **)
39
41
  @event = event
42
+ @railway = railway
40
43
  end
41
44
 
42
- def fetch(key)
45
+ def cache(key)
43
46
  event.cache.fetch(key) { event.cache[key] = yield }
44
47
  end
45
48
  end
@@ -1,3 +1,3 @@
1
1
  module DirtyPipeline
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirty_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Dolganov