activeinteractor 2.0.0.alpha.1.0.0 → 2.0.0.alpha.2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_interactor/base.rb +35 -9
- data/lib/active_interactor.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8353806528fdb9ad9625f469d16d400929d9ef3cae024490c85982354f4d9bad
|
4
|
+
data.tar.gz: af9cfad32cffe177d1b30fa7fb482f3305a6757152090d82482aef39f448a628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45a07cd05ee5ad9e27fb23f2ebe1a99c5bc01cdeeda5987e35a501b22230ecb56ea49ccc36c233348a838a6c25cd2fa8b6945326bef13839d1f4541a0d3ac043
|
7
|
+
data.tar.gz: c11cbf40fa73910ce12a43a60db15f13983ec6174006627eae29eecd068002be2fcbd50b7062d4cd0d955736594a246611f66c570db59b152e889053c9b5128d
|
@@ -7,8 +7,12 @@ module ActiveInteractor
|
|
7
7
|
attributes[:arguments][name.to_sym] = { name: name, type: type, description: description }.merge(options)
|
8
8
|
end
|
9
9
|
|
10
|
+
def perform!(input_context = {})
|
11
|
+
new(input_context).perform!
|
12
|
+
end
|
13
|
+
|
10
14
|
def perform(input_context = {})
|
11
|
-
|
15
|
+
perform!(input_context)
|
12
16
|
rescue Error => e
|
13
17
|
e.result
|
14
18
|
rescue StandardError => e
|
@@ -31,21 +35,37 @@ module ActiveInteractor
|
|
31
35
|
@context = parse_input!
|
32
36
|
end
|
33
37
|
|
34
|
-
def perform
|
38
|
+
def perform!
|
39
|
+
with_notification(:perform) do |payload|
|
40
|
+
interact
|
41
|
+
payload[:result] = Result.success(data: parse_output!)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def perform
|
46
|
+
perform!
|
47
|
+
rescue Error => e
|
48
|
+
e.result
|
49
|
+
rescue StandardError => e
|
50
|
+
Result.failure(errors: e.message)
|
51
|
+
end
|
52
|
+
|
53
|
+
def interact; end
|
35
54
|
def rollback; end
|
36
55
|
|
37
56
|
protected
|
38
57
|
|
39
58
|
attr_accessor :context
|
40
59
|
|
41
|
-
def exec_perform!
|
42
|
-
perform
|
43
|
-
Result.success(data: parse_output!)
|
44
|
-
end
|
45
|
-
|
46
60
|
def fail!(errors = {})
|
47
|
-
|
48
|
-
|
61
|
+
result = nil
|
62
|
+
with_notification(:rollback) do |payload|
|
63
|
+
rollback
|
64
|
+
result = Result.failure(data: parse_output!, errors: errors)
|
65
|
+
payload[:result] = result
|
66
|
+
end
|
67
|
+
|
68
|
+
raise Error, result
|
49
69
|
end
|
50
70
|
|
51
71
|
def parse_input!
|
@@ -79,5 +99,11 @@ module ActiveInteractor
|
|
79
99
|
errors[attribute_name] << :blank
|
80
100
|
errors
|
81
101
|
end
|
102
|
+
|
103
|
+
def with_notification(action)
|
104
|
+
ActiveSupport::Notifications.instrument("#{self.class.name}::#{action.to_s.classify}") do |payload|
|
105
|
+
yield payload if block_given?
|
106
|
+
end
|
107
|
+
end
|
82
108
|
end
|
83
109
|
end
|
data/lib/active_interactor.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeinteractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.alpha.1.0
|
4
|
+
version: 2.0.0.alpha.2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -72,9 +72,9 @@ licenses:
|
|
72
72
|
- MIT
|
73
73
|
metadata:
|
74
74
|
bug_tracker_uri: https://github.com/activeinteractor/activeinteractor/issues
|
75
|
-
changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.1.0
|
75
|
+
changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.1.0/CHANGELOG.md
|
76
76
|
homepage_uri: https://github.com/activeinteractor/activeinteractor
|
77
|
-
source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.1.0
|
77
|
+
source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.1.0
|
78
78
|
wiki_uri: https://github.com/activeinteractor/activeinteractor/wiki
|
79
79
|
rubygems_mfa_required: 'true'
|
80
80
|
post_install_message:
|