service_actor 3.9.2 → 3.9.4

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: f2483bd7441afe757bcfb29be028fdf518575f1c87c5c3470858248c78702db8
4
- data.tar.gz: 78f16e2ad2d5ca6169e3c21ede1672c23e24037f753c5072a6dee834444f53ca
3
+ metadata.gz: f91c36f4113eb695e8398ac43395dc85b5f51cb103c2dcdc72b8e351839932a7
4
+ data.tar.gz: f536f4d3d552d07544cd46706faca94240711758ba39da68e07db7e819236b24
5
5
  SHA512:
6
- metadata.gz: 9a80ea6854ca7084e4cf9f1acb3d706d4e749b52965f88a13ce48eb9769e5ce700195f18b760454a60855f92d408b29dd48fa7a58587d3f8b0a7a1647f53942e
7
- data.tar.gz: 467f81ee0496d1a22888df3388e41cf16755d288a2a6416ca0c9c774bfe5ab3d4a883e6a730a240271227626aa7a7dc65c3ce177e292051f28d477d718dfecf7
6
+ metadata.gz: 5e8260d8e84d2ef2c918e01eb13c8ac0417bff3cf3f0683acc3a3d6281184c9ef9d6af1c20d0cba3c65b74ba51a48ae3a72ba40e2c64280df936c307331957b4
7
+ data.tar.gz: 0a93c5b2eecc2e1cd7724b3a42ffd7664d4caa069de6066a2ae3f0c40fdc405492c0ec2cea964cf92df6016a34296c07acad48f7f018a6b46bd26a7864be5378
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Error raised when using `fail!` inside an actor.
3
+ # Default error raised when using `fail!` inside an actor.
4
4
  class ServiceActor::Failure < ServiceActor::Error
5
5
  def initialize(result)
6
6
  @result = result
@@ -116,7 +116,10 @@ module ServiceActor::Playable
116
116
  end
117
117
 
118
118
  def play_interactor(actor)
119
- result.merge!(actor.call(result.to_h).to_h)
119
+ interactor = actor.call(result.to_h)
120
+ result.merge!(interactor.to_h)
121
+ fail! if interactor.failure?
122
+ result
120
123
  end
121
124
  end
122
125
  end
@@ -14,9 +14,12 @@ class ServiceActor::Result < BasicObject
14
14
  %i[
15
15
  block_given?
16
16
  class
17
+ hash
18
+ instance_of?
17
19
  instance_variables
18
20
  is_a?
19
21
  kind_of?
22
+ methods
20
23
  nil?
21
24
  object_id
22
25
  private_methods
@@ -24,7 +27,6 @@ class ServiceActor::Result < BasicObject
24
27
  send
25
28
  tap
26
29
  then
27
- methods
28
30
  ].each do |method_name|
29
31
  define_method(method_name, ::Kernel.instance_method(method_name))
30
32
  end
@@ -33,7 +35,7 @@ class ServiceActor::Result < BasicObject
33
35
  alias_method :blank?, :nil?
34
36
 
35
37
  def initialize(data = {})
36
- @data = data.to_h
38
+ @data = data.to_h.transform_keys(&:to_sym)
37
39
  end
38
40
 
39
41
  def to_h
@@ -44,7 +46,11 @@ class ServiceActor::Result < BasicObject
44
46
  "<#{self.class.name} #{to_h}>"
45
47
  end
46
48
 
47
- alias_method :pretty_print, :inspect
49
+ def pretty_print(pp)
50
+ pp.text "#<#{self.class.name} "
51
+ pp.pp to_h
52
+ pp.text ">"
53
+ end
48
54
 
49
55
  def fail!(failure_class = nil, result = {})
50
56
  if failure_class.nil? || failure_class.is_a?(::Hash)
@@ -71,24 +77,32 @@ class ServiceActor::Result < BasicObject
71
77
  end
72
78
 
73
79
  def merge!(result)
74
- data.merge!(result)
80
+ data.merge!(result.transform_keys(&:to_sym))
75
81
 
76
82
  self
77
83
  end
78
84
 
79
85
  def key?(name)
86
+ name = name.to_sym
87
+
80
88
  to_h.key?(name)
81
89
  end
82
90
 
83
91
  def [](name)
92
+ name = name.to_sym
93
+
84
94
  data[name]
85
95
  end
86
96
 
87
97
  def []=(key, value)
98
+ key = key.to_sym
99
+
88
100
  data[key] = value
89
101
  end
90
102
 
91
103
  def delete!(key)
104
+ key = key.to_sym
105
+
92
106
  data.delete(key)
93
107
  end
94
108
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ServiceActor
4
- VERSION = "3.9.2"
4
+ VERSION = "3.9.4"
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.9.2
4
+ version: 3.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunny Ripert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-27 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-thread_safety
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0.1'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0.1'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: code-scanning-rubocop
155
169
  requirement: !ruby/object:Gem::Requirement