civil_service 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c81938a431b93fc416ce04cd6062971c03f6cb397b909afcca2c8b8e8bb1164a
4
- data.tar.gz: 1786acdbe99e9245bf0c8e244fada4d5dc84bc40cfab4b860bbe5d65faf81c46
3
+ metadata.gz: 3cc309b95109e1703e10facefa160b6b3ec0d2c9cdeecc55c4d7fcca4fd3b788
4
+ data.tar.gz: bd935e564c4170b464e0fc5a577d885201c4a506f57bd5dd67ca69ceb5f5de5a
5
5
  SHA512:
6
- metadata.gz: 80ffe9daa4f19ccb5b6aff3ead328758e4005b1cdccdac14cbbf66f8642d4b69c6d750bb0f50a1be03fc899dd1d6b8816de1b6db93847b8040b866e15a06e3ca
7
- data.tar.gz: ace5d7948426b071564cb8696a2da2c6a8362ec47b26b0a5593d2b1530e3db0d870f48a053744c441c52918ef81b770fbeb55c03986d2bbac8537b1a0f882af1
6
+ metadata.gz: 10fbcc6182d07401c5e13580246511f9b8d9de9724bf049e21e0b343dee7b147dd2447ad1b58660488366dd892e05cfd5a2dba30dfeb2bf02d7d526117f09316
7
+ data.tar.gz: cb07f3d6487e639cac8c0645dc2b316a0ef017986e7d3bea0e0eaef66e66f37241b34d08989f2c558e737a549afba2e8d8c0dd49ca9cdc642c7af9c0d7914578
data/CHANGELOG.md CHANGED
@@ -1,30 +1,36 @@
1
+ # Version 2.4.0 - January 15, 2021
2
+
3
+ - `#call`, `#call_and_raise`, and `#call!` now accept an optional keyword parameter called `validate`. This will
4
+ skip validations if passed `false`. (`true` is the default value.)
5
+ - `#call!` now takes advantage of the `validate:` parameter internally to avoid running validations twice.
6
+
1
7
  # Version 2.3.0 - April 3, 2020
2
8
 
3
- * `#call!` now raises the underlying exception if the service threw an exception,
9
+ - `#call!` now raises the underlying exception if the service threw an exception,
4
10
  rather than hiding it inside a `CivilService::ServiceFailure`.
5
11
 
6
12
  # Version 2.2.1 - October 4, 2019
7
13
 
8
- * `CivilService::MultiResultService::MultiResult#exception` now checks the underlying exception on
14
+ - `CivilService::MultiResultService::MultiResult#exception` now checks the underlying exception on
9
15
  the root result object, in case the service threw an exception.
10
16
 
11
17
  # Version 2.2.0 - September 26, 2019
12
18
 
13
- * Services now have a new `#call_and_raise` method, which will return a result object on failure
19
+ - Services now have a new `#call_and_raise` method, which will return a result object on failure
14
20
  but will raise exceptions that are thrown inside the service call (effectively, the behavior of
15
21
  `#call` in CivilService 1.0.0).
16
- * Added a new mixin called `CivilService::MultiResultService`, which allows creating services whose
22
+ - Added a new mixin called `CivilService::MultiResultService`, which allows creating services whose
17
23
  results are composed of multiple results that are aggregated together.
18
24
 
19
25
  # Version 2.1.0 - September 25, 2019
20
26
 
21
- * `CivilService::Result#errors` now always returns an Errors object even if it hasn't been
27
+ - `CivilService::Result#errors` now always returns an Errors object even if it hasn't been
22
28
  explicitly set.
23
29
 
24
30
  # Version 2.0.0 - June 26, 2019
25
31
 
26
- * BREAKING CHANGE: The behavior of `CivilService::Service#call` has changed when exceptions are
27
- raised inside the service. The `call` method will now catch the exception and return a failing
32
+ - BREAKING CHANGE: The behavior of `CivilService::Service#call` has changed when exceptions are
33
+ raised inside the service. The `call` method will now catch the exception and return a failing
28
34
  result object, with the exception message as an error on `:base`.
29
35
 
30
36
  The behavior of `call!` has not changed: a failing result will be raised as a
@@ -35,8 +41,9 @@
35
41
  will (almost) never raise an exception, whereas `call!` can raise an exception.
36
42
 
37
43
  The exception to this rule (pun intended, always intend your puns) is that `call` will not catch
38
- exceptions that don't inherit from `StandardError`, such as `SystemExit`. See
44
+ exceptions that don't inherit from `StandardError`, such as `SystemExit`. See
39
45
  [Honeybadger's explanation](https://www.honeybadger.io/blog/a-beginner-s-guide-to-exceptions-in-ruby/)
40
46
  of why this is a good idea.
41
- * `CivilService::Result` now has an additional attribute called `exception`, which can be used to
47
+
48
+ - `CivilService::Result` now has an additional attribute called `exception`, which can be used to
42
49
  retrieve an exception thrown inside a `call` method.
data/Gemfile.lock CHANGED
@@ -1,29 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- civil_service (2.3.0)
4
+ civil_service (2.4.0)
5
5
  activemodel (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.0.0)
11
- activesupport (= 6.0.0)
12
- activesupport (6.0.0)
10
+ activemodel (7.0.0)
11
+ activesupport (= 7.0.0)
12
+ activesupport (7.0.0)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.1, >= 2.1.8)
18
- concurrent-ruby (1.1.6)
19
- i18n (1.8.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ concurrent-ruby (1.1.9)
18
+ i18n (1.8.11)
20
19
  concurrent-ruby (~> 1.0)
21
20
  minitest (5.11.3)
22
21
  rake (13.0.1)
23
- thread_safe (0.3.6)
24
- tzinfo (1.2.6)
25
- thread_safe (~> 0.1)
26
- zeitwerk (2.2.0)
22
+ tzinfo (2.0.4)
23
+ concurrent-ruby (~> 1.0)
27
24
 
28
25
  PLATFORMS
29
26
  ruby
@@ -12,8 +12,8 @@ class CivilService::Service
12
12
  end
13
13
  end
14
14
 
15
- def call
16
- unless self.class.validate_manually
15
+ def call(validate: true)
16
+ if validate && !self.class.validate_manually
17
17
  return failure(errors) unless valid?
18
18
  end
19
19
 
@@ -25,8 +25,8 @@ class CivilService::Service
25
25
  end
26
26
  end
27
27
 
28
- def call_and_raise
29
- result = call
28
+ def call_and_raise(validate: true)
29
+ result = call(validate: validate)
30
30
  if result.exception
31
31
  raise result.exception, result.exception.message, result.exception.backtrace
32
32
  end
@@ -34,12 +34,12 @@ class CivilService::Service
34
34
  result
35
35
  end
36
36
 
37
- def call!
38
- unless self.class.validate_manually
37
+ def call!(validate: true)
38
+ if validate && !self.class.validate_manually
39
39
  raise CivilService::ServiceFailure.new(self, failure(errors)) unless valid?
40
40
  end
41
41
 
42
- result = call_and_raise
42
+ result = call_and_raise(validate: false) # we already just did the validation step if needed
43
43
  raise CivilService::ServiceFailure.new(self, result) if result.failure?
44
44
  result
45
45
  end
@@ -1,3 +1,3 @@
1
1
  module CivilService
2
- VERSION = '2.3.0'
2
+ VERSION = '2.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civil_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2022-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -96,7 +96,7 @@ files:
96
96
  homepage: https://github.com/neinteractiveliterature/civil_service
97
97
  licenses: []
98
98
  metadata: {}
99
- post_install_message:
99
+ post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
102
102
  - lib
@@ -111,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.0.3
115
- signing_key:
114
+ rubygems_version: 3.1.6
115
+ signing_key:
116
116
  specification_version: 4
117
117
  summary: A tiny service object framework for Rails apps
118
118
  test_files: []