ii_interactor 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +7 -1
- data/CHANGELOG.md +4 -0
- data/bin/console +2 -2
- data/gemfiles/rails60.gemfile +1 -0
- data/gemfiles/rails70.gemfile +1 -1
- data/ii_interactor.gemspec +1 -1
- data/lib/ii_interactor/context.rb +24 -12
- data/lib/ii_interactor/core.rb +1 -1
- data/lib/ii_interactor/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d41caaf17018a5faf867b26ee15e97c68afbf3126e69ce4a81fc5c0b2394345
|
4
|
+
data.tar.gz: dbe6665d293c2f8c42030592ebdbe7671f57c7737ddd28f50c326539e2635536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c35516d55b89a9e37d56b5b280df3840c96b378ae37cba70d46ad5d5aff694b1c66b2029871028ff72db71293490b232a6796e4e9575eaacbe5d1b353c27f0
|
7
|
+
data.tar.gz: f25a6c2e3923c06d7aac135059979108c207953f0034bea8039ed159b88a4ab8adcfbe3f4019ca6c3b5bcf77e7415bde97c11adabb310c64b3bed4621b8e8e04
|
data/.github/workflows/ci.yml
CHANGED
@@ -8,7 +8,7 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
|
-
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
|
11
|
+
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1]
|
12
12
|
gemfile: ['rails50', 'rails51', 'rails52', 'rails60', 'rails61', 'rails70']
|
13
13
|
exclude:
|
14
14
|
- ruby: 2.3
|
@@ -33,6 +33,12 @@ jobs:
|
|
33
33
|
gemfile: rails51
|
34
34
|
- ruby: 3.0
|
35
35
|
gemfile: rails52
|
36
|
+
- ruby: 3.1
|
37
|
+
gemfile: rails50
|
38
|
+
- ruby: 3.1
|
39
|
+
gemfile: rails51
|
40
|
+
- ruby: 3.1
|
41
|
+
gemfile: rails52
|
36
42
|
|
37
43
|
name: ruby ${{ matrix.ruby }}, ${{ matrix.gemfile }}
|
38
44
|
|
data/CHANGELOG.md
CHANGED
data/bin/console
CHANGED
data/gemfiles/rails60.gemfile
CHANGED
data/gemfiles/rails70.gemfile
CHANGED
data/ii_interactor.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "activesupport", ">= 5.0"
|
21
|
-
spec.add_dependency "coactive", ">= 0.
|
21
|
+
spec.add_dependency "coactive", ">= 0.3"
|
22
22
|
|
23
23
|
spec.add_development_dependency "rails", ">= 5.0"
|
24
24
|
spec.add_development_dependency "sqlite3"
|
@@ -2,21 +2,33 @@
|
|
2
2
|
|
3
3
|
module IIInteractor
|
4
4
|
class Context < Coactive::Context
|
5
|
+
class Status < Struct.new(:failed, :stopped, :called)
|
6
|
+
def initialize(*)
|
7
|
+
self.failed = false
|
8
|
+
self.stopped = false
|
9
|
+
self.called = []
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :_status, :_block
|
14
|
+
|
5
15
|
def initialize(data = {}, &block)
|
16
|
+
if data.is_a?(IIInteractor::Context)
|
17
|
+
@_block = data._block
|
18
|
+
@_status = data._status
|
19
|
+
else
|
20
|
+
@_block = block
|
21
|
+
@_status = Status.new
|
22
|
+
end
|
6
23
|
super
|
7
|
-
@_data[:_block] ||= block
|
8
|
-
@_data[:_failed] ||= false
|
9
|
-
@_data[:_stopped] ||= false
|
10
|
-
@_data[:_called] ||= []
|
11
24
|
end
|
12
25
|
|
13
26
|
def to_s
|
14
|
-
|
15
|
-
"#<#{self.class} #{attrs}>"
|
27
|
+
"#<#{self.class} #{self.class.inspect(@_data)} (#{self.class.inspect(@_status.to_h)})>"
|
16
28
|
end
|
17
29
|
|
18
30
|
def call_block!(*args)
|
19
|
-
@
|
31
|
+
@_block.call(*args) if @_block
|
20
32
|
end
|
21
33
|
|
22
34
|
def success?
|
@@ -24,27 +36,27 @@ module IIInteractor
|
|
24
36
|
end
|
25
37
|
|
26
38
|
def failure?
|
27
|
-
@
|
39
|
+
@_status.failed == true
|
28
40
|
end
|
29
41
|
|
30
42
|
def stopped?
|
31
|
-
@
|
43
|
+
@_status.stopped == true
|
32
44
|
end
|
33
45
|
|
34
46
|
def fail!(data = {})
|
35
|
-
@
|
47
|
+
@_status.failed = true
|
36
48
|
data.each { |k, v| @_data[k] = v }
|
37
49
|
define_accessors!(data.keys)
|
38
50
|
end
|
39
51
|
|
40
52
|
def stop!(data = {})
|
41
|
-
@
|
53
|
+
@_status.stopped = true
|
42
54
|
data.each { |k, v| @_data[k] = v }
|
43
55
|
define_accessors!(data.keys)
|
44
56
|
end
|
45
57
|
|
46
58
|
def called!(interactor)
|
47
|
-
@
|
59
|
+
@_status.called << interactor
|
48
60
|
end
|
49
61
|
end
|
50
62
|
end
|
data/lib/ii_interactor/core.rb
CHANGED
@@ -65,7 +65,7 @@ module IIInteractor
|
|
65
65
|
interactor.call_all
|
66
66
|
interactor.context
|
67
67
|
rescue UnprogressableError
|
68
|
-
interactor.context
|
68
|
+
interactor.context._status.called.reverse.each do |called|
|
69
69
|
called.rollback
|
70
70
|
end
|
71
71
|
interactor.context
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ii_interactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshikazu Kaneta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.3.3
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: A base interactor to support management of bussiness logic
|