actioninteractor 0.0.7 → 0.0.8
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 +5 -5
- data/lib/action_interactor/base.rb +18 -0
- data/test/base_test.rb +7 -0
- data/test/inheritance_test.rb +13 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56f8b129a2e8cd1e7daa107e94c086e08271c74ffb69f1f183aee686a39e05c3
|
4
|
+
data.tar.gz: 564ad42fc890791b41ae055cbf5521b474f529a161843732ca3006316faf9ba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84550f329cebab3347c79bf66bf3a73fa7cadf83ee121e17da4b1f8a1bb5d9b4220f8a003852eb4d9afa595d277a66d0d970662bf821316b627736edb55f308
|
7
|
+
data.tar.gz: 31711fa714666d1c2cc16c2f0525766c360af9354325d4e63a572e2dd4d0b553f607bfc677463b5745c58ad569685e0f7e5a0fb1057fa39b2a77d16b474178ae
|
@@ -16,6 +16,10 @@ module ActionInteractor
|
|
16
16
|
@completed
|
17
17
|
end
|
18
18
|
|
19
|
+
def incomplete?
|
20
|
+
!completed?
|
21
|
+
end
|
22
|
+
|
19
23
|
def success?
|
20
24
|
@success
|
21
25
|
end
|
@@ -24,6 +28,10 @@ module ActionInteractor
|
|
24
28
|
!success?
|
25
29
|
end
|
26
30
|
|
31
|
+
def aborted?
|
32
|
+
failure? && incomplete?
|
33
|
+
end
|
34
|
+
|
27
35
|
def reset!
|
28
36
|
@result = {}
|
29
37
|
fail!
|
@@ -35,6 +43,16 @@ module ActionInteractor
|
|
35
43
|
complete!
|
36
44
|
end
|
37
45
|
|
46
|
+
def failed!
|
47
|
+
fail!
|
48
|
+
complete!
|
49
|
+
end
|
50
|
+
|
51
|
+
def abort!
|
52
|
+
fail!
|
53
|
+
incomplete!
|
54
|
+
end
|
55
|
+
|
38
56
|
def success!
|
39
57
|
@success = true
|
40
58
|
end
|
data/test/base_test.rb
CHANGED
@@ -30,4 +30,11 @@ class BaseTest < Test::Unit::TestCase
|
|
30
30
|
interactor = ActionInteractor::Base.execute(params)
|
31
31
|
assert interactor.completed?
|
32
32
|
end
|
33
|
+
|
34
|
+
test "#aborted? is true after #abort!" do
|
35
|
+
params = {}
|
36
|
+
interactor = ActionInteractor::Base.execute(params)
|
37
|
+
interactor.abort!
|
38
|
+
assert interactor.aborted?
|
39
|
+
end
|
33
40
|
end
|
data/test/inheritance_test.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
class RegistrationInteractor < ActionInteractor::Base
|
13
13
|
def execute
|
14
|
-
return unless params[:name]
|
14
|
+
return failed! unless params[:name]
|
15
15
|
add_result(:user, User.new(name: params[:name]))
|
16
16
|
finish!
|
17
17
|
end
|
@@ -53,4 +53,16 @@ class InheritanceTest < Test::Unit::TestCase
|
|
53
53
|
interactor = RegistrationInteractor.execute(params)
|
54
54
|
assert interactor.completed?
|
55
55
|
end
|
56
|
+
|
57
|
+
test "if params is empty, #failure? is true" do
|
58
|
+
params = {}
|
59
|
+
interactor = RegistrationInteractor.execute(params)
|
60
|
+
assert interactor.failure?
|
61
|
+
end
|
62
|
+
|
63
|
+
test "if params is empty, #completed? is true" do
|
64
|
+
params = {}
|
65
|
+
interactor = RegistrationInteractor.execute(params)
|
66
|
+
assert interactor.completed?
|
67
|
+
end
|
56
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actioninteractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: 1.8.11
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
74
|
+
rubygems_version: 2.7.6
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Action Interactor provides a simple interface for performing operations (part
|