ii_interactor 2.1.0 → 2.2.1
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 +14 -2
- data/CHANGELOG.md +8 -0
- data/bin/console +2 -2
- data/gemfiles/rails50.gemfile +1 -0
- data/gemfiles/rails51.gemfile +1 -0
- data/gemfiles/rails52.gemfile +1 -0
- 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/log_subscriber.rb +2 -2
- 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: f6b2635fa972f56d9ec9fe34b487411b9021e41cff5d2da7dfe5977d954a901d
|
4
|
+
data.tar.gz: d585efc287ffa979969a47fb2257689d025f6f9719b4bb09168d019fd9c51f35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45044189f8450083926b037a0999f82c1c03ab1aae721369cbc53c9506ab60904159f2660c1ad1f369635c59ed59d1c7c688b5bee5d52742f1e7fc844f687752
|
7
|
+
data.tar.gz: 85342c80ea1992ffc5a9b7042eb3dba442cb510d0e494f4d478dec8bb7b93d764916bd55144c6ad6e209479ace00e378323c95214be1691a27f30680e0d48e49
|
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, 3.2]
|
12
12
|
gemfile: ['rails50', 'rails51', 'rails52', 'rails60', 'rails61', 'rails70']
|
13
13
|
exclude:
|
14
14
|
- ruby: 2.3
|
@@ -33,6 +33,18 @@ 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
|
42
|
+
- ruby: 3.2
|
43
|
+
gemfile: rails50
|
44
|
+
- ruby: 3.2
|
45
|
+
gemfile: rails51
|
46
|
+
- ruby: 3.2
|
47
|
+
gemfile: rails52
|
36
48
|
|
37
49
|
name: ruby ${{ matrix.ruby }}, ${{ matrix.gemfile }}
|
38
50
|
|
@@ -40,7 +52,7 @@ jobs:
|
|
40
52
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
41
53
|
|
42
54
|
steps:
|
43
|
-
- uses: actions/checkout@
|
55
|
+
- uses: actions/checkout@v3
|
44
56
|
- uses: ruby/setup-ruby@v1
|
45
57
|
with:
|
46
58
|
ruby-version: ${{ matrix.ruby }}
|
data/CHANGELOG.md
CHANGED
data/bin/console
CHANGED
data/gemfiles/rails50.gemfile
CHANGED
data/gemfiles/rails51.gemfile
CHANGED
data/gemfiles/rails52.gemfile
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
|
@@ -5,14 +5,14 @@ module IIInteractor
|
|
5
5
|
def calling(event)
|
6
6
|
debug do
|
7
7
|
interactor = event.payload[:interactor]
|
8
|
-
"Calling #{interactor.class} with #{interactor.context}"
|
8
|
+
" Calling #{interactor.class} with #{interactor.context}"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(event)
|
13
13
|
debug do
|
14
14
|
interactor = event.payload[:interactor]
|
15
|
-
"Called #{interactor.class} (#{additional_log(event)})"
|
15
|
+
" Called #{interactor.class} (#{additional_log(event)})"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
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.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshikazu Kaneta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-25 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
|