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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd30f97e96402732d11711e040cd4a65ab96962a60338a5358bcae13c9578b06
4
- data.tar.gz: 42694afe490d30e236c3a42bde46547759fd5adf7d8a52556dc7838a45be937e
3
+ metadata.gz: '0597123f9fd025cb0fdd1d099c9a4c29865a086a107d67f7b336b3828e6743c5'
4
+ data.tar.gz: fa2e8c72f82970ff779f1c870fa4074630b7e4d2d947f10f57e8a0670a9bae07
5
5
  SHA512:
6
- metadata.gz: 6d5d01ce6b421df89f2074753c84ee84c9d166219316ee92c69a2d35e186f28faad4482e020c1144cac05caf1ca0ee2e56ee567dd1793f8bbf33c5b87dea31df
7
- data.tar.gz: '038d365e4f8cff50b7fbc71ba757da5095d62487cd1e043338f386e9c04dd49fd1fe99081d84f7c4ac94f30b3bc35774ea6460825ae98c6380aa17760f8f133d'
6
+ metadata.gz: 73dea56535940a843c9cf9bee977882293a0dd2ad4b6c0d3069fe28ea4b7d2569f3c3508cc68f8d378ebb526b00027b72a232373049bcf541e91861fe558d589
7
+ data.tar.gz: 282acf3196702a03f15e8faba840abdf68075abcc3e132dce6efcb090c5349b426f8261bd13fafc68f4e4fbac2a25a1401da8ad9b2638eb1d2a907cb548c8887
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # ServiceActor
2
2
 
3
- ![Tests](https://github.com/sunny/actor/workflows/Tests/badge.svg)
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
- check, message = define_check_and_message_from(nested_check_conditions)
58
+ message = prepared_message_with(nested_check_name, nested_check_conditions) # rubocop:disable Layout/LineLength
59
59
 
60
- next if check.call(@value)
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)
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ServiceActor
4
- VERSION = "3.6.0"
4
+ VERSION = "3.6.1"
5
5
  end
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.0
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: 2022-12-29 00:00:00.000000000 Z
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.1.6
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: []