amazing-activist 0.2.0 → 0.3.0
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 +4 -4
- data/README.adoc +1 -1
- data/lib/amazing_activist/base.rb +10 -2
- data/lib/amazing_activist/outcome/failure.rb +22 -12
- data/lib/amazing_activist/outcome/success.rb +4 -4
- data/lib/amazing_activist/unwrap_error.rb +5 -0
- data/lib/amazing_activist/version.rb +1 -1
- metadata +5 -6
- data/CHANGELOG.md +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a9d6f3426a86d93d6affd8f54d19f7f071cb5142636c1b3b6fc2a12fbe87b9
|
4
|
+
data.tar.gz: d53b13cc039dee609e0d2870c560932942d3aa38009b4e7a742f7ce7ad44e9df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0549ced0fb0312fd5c4cca4cfc8ccaa0e359584c868497a5eea3caa7ad246958de12566d5f33525d555f6bbd9c3a77eb3536514d0e555b83a8a629048c3d58ff'
|
7
|
+
data.tar.gz: de8d63d94501dc73c61cc626e899407846af44dc8e9cb1c603e7154d57a57720adaa0897a319782a458ed9d89eff474a510777f5083206b9da902143f89060bd
|
data/README.adoc
CHANGED
@@ -18,6 +18,14 @@ module AmazingActivist
|
|
18
18
|
# failure(:invalid_params, user: user)
|
19
19
|
# end
|
20
20
|
# end
|
21
|
+
#
|
22
|
+
# case OnboardActivity.call(email: "user@example.com")
|
23
|
+
# in success: user
|
24
|
+
# Current.user = user
|
25
|
+
# redirect_to dashboard_url
|
26
|
+
# else
|
27
|
+
# render :new, status: :unprocessable_entity
|
28
|
+
# end
|
21
29
|
# ----
|
22
30
|
class Base
|
23
31
|
class << self
|
@@ -53,8 +61,8 @@ module AmazingActivist
|
|
53
61
|
# @param code (see Outcome::Failure#initialize)
|
54
62
|
# @param context (see Outcome::Failure#initialize)
|
55
63
|
# @return [Outcome::Failure]
|
56
|
-
def failure(code,
|
57
|
-
Outcome::Failure.new(code, activity: self, context: context)
|
64
|
+
def failure(code, message: nil, exception: nil, context: {})
|
65
|
+
Outcome::Failure.new(code, activity: self, message: message, exception: exception, context: context)
|
58
66
|
end
|
59
67
|
end
|
60
68
|
end
|
@@ -9,19 +9,26 @@ module AmazingActivist
|
|
9
9
|
# @return [Symbol]
|
10
10
|
attr_reader :code
|
11
11
|
|
12
|
-
# @return [AmazingActivist::
|
12
|
+
# @return [AmazingActivist::Base]
|
13
13
|
attr_reader :activity
|
14
14
|
|
15
|
-
# @return [
|
15
|
+
# @return [Exception, nil]
|
16
|
+
attr_reader :exception
|
17
|
+
|
18
|
+
# @return [Hash]
|
16
19
|
attr_reader :context
|
17
20
|
|
18
21
|
# @param code [#to_sym]
|
19
22
|
# @param activity [AmazingActivist::Activity]
|
20
|
-
# @param
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@
|
23
|
+
# @param message [#to_s, nil]
|
24
|
+
# @param exception [Exception, nil]
|
25
|
+
# @param context [Hash]
|
26
|
+
def initialize(code, activity:, message:, exception:, context:)
|
27
|
+
@code = code.to_sym
|
28
|
+
@activity = activity
|
29
|
+
@message = message&.to_s
|
30
|
+
@exception = exception
|
31
|
+
@context = context
|
25
32
|
end
|
26
33
|
|
27
34
|
# @return [true]
|
@@ -35,15 +42,15 @@ module AmazingActivist
|
|
35
42
|
end
|
36
43
|
|
37
44
|
# @api internal
|
38
|
-
# @return [Array
|
45
|
+
# @return [Array]
|
39
46
|
def deconstruct
|
40
|
-
[:failure, @code, @activity
|
47
|
+
[:failure, @code, @activity]
|
41
48
|
end
|
42
49
|
|
43
50
|
# @api internal
|
44
|
-
# @return [Hash
|
51
|
+
# @return [Hash]
|
45
52
|
def deconstruct_keys(_)
|
46
|
-
{ failure: @code, activity: @activity, context:
|
53
|
+
{ failure: @code, activity: @activity, message: message, exception: exception, context: context }
|
47
54
|
end
|
48
55
|
|
49
56
|
# @yieldparam self [self]
|
@@ -56,8 +63,11 @@ module AmazingActivist
|
|
56
63
|
raise UnwrapError, self
|
57
64
|
end
|
58
65
|
|
66
|
+
# Failure message.
|
67
|
+
#
|
68
|
+
# @return [String]
|
59
69
|
def message
|
60
|
-
@
|
70
|
+
@message || Polyglot.new(@activity).message(@code, **context)
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
module AmazingActivist
|
4
4
|
module Outcome
|
5
5
|
class Success
|
6
|
-
# @return [AmazingActivist::
|
6
|
+
# @return [AmazingActivist::Base]
|
7
7
|
attr_reader :activity
|
8
8
|
|
9
9
|
# @param value [Object]
|
10
|
-
# @param activity [AmazingActivist::
|
10
|
+
# @param activity [AmazingActivist::Base]
|
11
11
|
def initialize(value, activity:)
|
12
12
|
@value = value
|
13
13
|
@activity = activity
|
@@ -24,13 +24,13 @@ module AmazingActivist
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# @api internal
|
27
|
-
# @return [Array
|
27
|
+
# @return [Array]
|
28
28
|
def deconstruct
|
29
29
|
[:success, @value, @activity]
|
30
30
|
end
|
31
31
|
|
32
32
|
# @api internal
|
33
|
-
# @return [Hash
|
33
|
+
# @return [Hash]
|
34
34
|
def deconstruct_keys(_)
|
35
35
|
{ success: @value, activity: @activity }
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazing-activist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -45,7 +45,6 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- CHANGELOG.md
|
49
48
|
- LICENSE.txt
|
50
49
|
- README.adoc
|
51
50
|
- lib/amazing-activist.rb
|
@@ -65,9 +64,9 @@ licenses:
|
|
65
64
|
- MIT
|
66
65
|
metadata:
|
67
66
|
homepage_uri: https://github.com/ixti/amazing-activist
|
68
|
-
source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.
|
67
|
+
source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.3.0
|
69
68
|
bug_tracker_uri: https://github.com/ixti/amazing-activist/issues
|
70
|
-
changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.
|
69
|
+
changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.3.0/CHANGES.md
|
71
70
|
rubygems_mfa_required: 'true'
|
72
71
|
post_install_message:
|
73
72
|
rdoc_options: []
|
@@ -84,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
83
|
- !ruby/object:Gem::Version
|
85
84
|
version: '0'
|
86
85
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.5.4
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: Your friendly neighborhood activist.
|
data/CHANGELOG.md
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file.
|
4
|
-
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
-
|
8
|
-
## [Unreleased]
|
9
|
-
|
10
|
-
|
11
|
-
## [0.2.0] - 2024-01-28
|
12
|
-
|
13
|
-
## Added
|
14
|
-
|
15
|
-
- Generate default failure messages with
|
16
|
-
[i18n](https://github.com/ruby-i18n/i18n).
|
17
|
-
|
18
|
-
|
19
|
-
## [0.1.0] - 2024-01-27
|
20
|
-
|
21
|
-
## Added
|
22
|
-
|
23
|
-
- Initial release.
|
24
|
-
|
25
|
-
[0.1.0]: https://github.com/ixti/sidekiq-antidote/tree/v0.1.0
|