strum-service 0.0.2 → 0.0.3

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: '0710157868640a5904ef6996d2e13f1b91cdcca1025b6a0b95b9230853ba3609'
4
- data.tar.gz: 5d8a21d6d8fb7751e780881cad8ba3f7a02556868b50a82e99455f41b98166c9
3
+ metadata.gz: 9e9cf711054f4a87537d4e9200065324ab9957f546f4dd156b8efde9dc0bb109
4
+ data.tar.gz: f261527adff9e339fa220c0557c5631d223a87b5542082b26f0cfa0e41d7f719
5
5
  SHA512:
6
- metadata.gz: 8af13f2c86dbea7ba37f27a32e1076d1a14f0122682dc8e5e27f1f4ead683545a2acc03fc1b4a071c5942fdadf1b8f2967a6f8f246f75f55432fca051182396a
7
- data.tar.gz: aae52d447451bdab8b023f529802af7eee7d95ee5eb6191a4e330782a4838ea0d79cdd3c04c54affad0136e0a2cc0fc8442eafc4416f6d57b221558bdab079e3
6
+ metadata.gz: acb83d0690366234a774fdb9e982ab2d7ca16e36967a8aef313a4b69253b7c7464d336b466e3dd4e3a1eb4ee722c2dc8d5a275514d7a49cecfeb34ca2aa06820
7
+ data.tar.gz: da811b26cd5f43678c28fbc76b4c6b17a23d5015b74aa58cbf16e736b301ea79ed2cc7c5acb8ccfa68bc9bcf0ba1f67e5a4178a10a803f6e699cd601b2bd4f74
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strum-service (0.0.2)
4
+ strum-service (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/strum/service.rb CHANGED
@@ -13,6 +13,16 @@ module Strum
13
13
  end
14
14
  end
15
15
 
16
+ # Define coercive methods
17
+ COERCIVE_METHODS = %i[add_error add_errors any required sliced sliced_list].freeze
18
+
19
+ COERCIVE_METHODS.each do |m|
20
+ define_method("#{m}!") do |*args, **kwargs, &block|
21
+ send(m, *args, **kwargs, &block)
22
+ throw :exit unless valid?
23
+ end
24
+ end
25
+
16
26
  # Internal: Interactor class methods.
17
27
  module ClassMethods
18
28
  def call(main_input, **args, &block)
@@ -30,9 +40,11 @@ module Strum
30
40
  end
31
41
 
32
42
  def execute
33
- audit
34
- yield(self) if block_given?
35
- call if valid?
43
+ catch(:exit) do
44
+ audit
45
+ yield(self) if block_given?
46
+ call if valid?
47
+ end
36
48
  valid? ? valid_result : invalid_result
37
49
  end
38
50
 
@@ -120,7 +132,7 @@ module Strum
120
132
 
121
133
  def add_error(field, value)
122
134
  strum_errors[field] ||= []
123
- strum_errors[field] = strum_errors[field] + Array(value)
135
+ strum_errors[field] += Array(value)
124
136
  end
125
137
 
126
138
  def add_errors(errors)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Strum
4
4
  module Service
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strum-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhiy Nazarov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Strum Service
14
14
  email: