service_actor 3.6.0 → 3.6.1
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.md +0 -2
- data/lib/service_actor/checks/must_check.rb +13 -2
- data/lib/service_actor/result.rb +6 -1
- data/lib/service_actor/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0597123f9fd025cb0fdd1d099c9a4c29865a086a107d67f7b336b3828e6743c5'
|
4
|
+
data.tar.gz: fa2e8c72f82970ff779f1c870fa4074630b7e4d2d947f10f57e8a0670a9bae07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73dea56535940a843c9cf9bee977882293a0dd2ad4b6c0d3069fe28ea4b7d2569f3c3508cc68f8d378ebb526b00027b72a232373049bcf541e91861fe558d589
|
7
|
+
data.tar.gz: 282acf3196702a03f15e8faba840abdf68075abcc3e132dce6efcb090c5349b426f8261bd13fafc68f4e4fbac2a25a1401da8ad9b2638eb1d2a907cb548c8887
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# ServiceActor
|
2
2
|
|
3
|
-

|
4
|
-
|
5
3
|
This Ruby gem lets you move your application logic into into small composable
|
6
4
|
service objects. It is a lightweight framework that helps you keep your models
|
7
5
|
and controllers thin.
|
@@ -55,9 +55,9 @@ class ServiceActor::Checks::MustCheck < ServiceActor::Checks::Base
|
|
55
55
|
|
56
56
|
def check
|
57
57
|
@nested_checks.each do |nested_check_name, nested_check_conditions|
|
58
|
-
|
58
|
+
message = prepared_message_with(nested_check_name, nested_check_conditions) # rubocop:disable Layout/LineLength
|
59
59
|
|
60
|
-
next
|
60
|
+
next unless message
|
61
61
|
|
62
62
|
add_argument_error(
|
63
63
|
message,
|
@@ -73,6 +73,17 @@ class ServiceActor::Checks::MustCheck < ServiceActor::Checks::Base
|
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
|
+
def prepared_message_with(nested_check_name, nested_check_conditions)
|
77
|
+
check, message = define_check_and_message_from(nested_check_conditions)
|
78
|
+
|
79
|
+
return if check.call(@value)
|
80
|
+
|
81
|
+
message
|
82
|
+
rescue StandardError => e
|
83
|
+
"The \"#{@input_key}\" input on \"#{@actor}\" has an error in the code " \
|
84
|
+
"inside \"#{nested_check_name}\": [#{e.class}] #{e.message}"
|
85
|
+
end
|
86
|
+
|
76
87
|
def define_check_and_message_from(nested_check_conditions)
|
77
88
|
if nested_check_conditions.is_a?(Hash)
|
78
89
|
nested_check_conditions.values_at(:is, :message)
|
data/lib/service_actor/result.rb
CHANGED
@@ -15,7 +15,12 @@ class ServiceActor::Result < OpenStruct
|
|
15
15
|
"<#{self.class.name} #{to_h}>"
|
16
16
|
end
|
17
17
|
|
18
|
-
def fail!(failure_class, result = {})
|
18
|
+
def fail!(failure_class = nil, result = {})
|
19
|
+
if failure_class.nil? || failure_class.is_a?(Hash)
|
20
|
+
result = failure_class.to_h
|
21
|
+
failure_class = ServiceActor::Failure
|
22
|
+
end
|
23
|
+
|
19
24
|
merge!(result)
|
20
25
|
merge!(failure?: true)
|
21
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_actor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Ripert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -196,7 +196,7 @@ metadata:
|
|
196
196
|
source_code_uri: https://github.com/sunny/actor
|
197
197
|
changelog_uri: https://github.com/sunny/actor/blob/main/CHANGELOG.md
|
198
198
|
rubygems_mfa_required: 'true'
|
199
|
-
post_install_message:
|
199
|
+
post_install_message:
|
200
200
|
rdoc_options: []
|
201
201
|
require_paths:
|
202
202
|
- lib
|
@@ -211,8 +211,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
211
|
- !ruby/object:Gem::Version
|
212
212
|
version: '0'
|
213
213
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
215
|
-
signing_key:
|
214
|
+
rubygems_version: 3.3.26
|
215
|
+
signing_key:
|
216
216
|
specification_version: 4
|
217
217
|
summary: Service objects for your application logic
|
218
218
|
test_files: []
|