service_actor 3.9.0 → 3.9.2

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: 240bbafeef337eec8bdb7f265b1c5ad1715ae4909967e65eb0fb313d3aaa74e8
4
- data.tar.gz: 7b8a442ff7ffec97bc9cd1466f5c6a2074e10bfa7edf6319468138acb37ad0d0
3
+ metadata.gz: f2483bd7441afe757bcfb29be028fdf518575f1c87c5c3470858248c78702db8
4
+ data.tar.gz: 78f16e2ad2d5ca6169e3c21ede1672c23e24037f753c5072a6dee834444f53ca
5
5
  SHA512:
6
- metadata.gz: b8491915f458d3dae52063f3d4f2131c246101dd50393a9de921d7e68e6189f0eddbc87910438bd8f9a9a68f36f72a5b50c121c4879f07053ad1f0e2ec61be16
7
- data.tar.gz: 4be5e6db8633232e0af626c0c71cb978c78b05be9082058f7bad3aeb81fa485975ade749f8be830f26ac049dc543c78553e0d0182e7d066e1c6e535bb2760fc2
6
+ metadata.gz: 9a80ea6854ca7084e4cf9f1acb3d706d4e749b52965f88a13ce48eb9769e5ce700195f18b760454a60855f92d408b29dd48fa7a58587d3f8b0a7a1647f53942e
7
+ data.tar.gz: 467f81ee0496d1a22888df3388e41cf16755d288a2a6416ca0c9c774bfe5ab3d4a883e6a730a240271227626aa7a7dc65c3ce177e292051f28d477d718dfecf7
@@ -4,6 +4,7 @@ module ServiceActor::ArgumentsValidator
4
4
  module_function
5
5
 
6
6
  def validate_origin_name(name, origin:)
7
+ return if name.to_sym == :error
7
8
  return unless ServiceActor::Result.instance_methods.include?(name.to_sym)
8
9
 
9
10
  raise ArgumentError,
@@ -90,16 +90,19 @@ module ServiceActor::Playable
90
90
  end
91
91
 
92
92
  def play_actor(actor)
93
- play_service_actor(actor) ||
94
- play_method(actor) ||
95
- play_interactor(actor) ||
93
+ if actor.is_a?(Symbol)
94
+ send(actor)
95
+ elsif actor.is_a?(Class) && actor.ancestors.include?(ServiceActor::Core)
96
+ play_service_actor(actor)
97
+ elsif actor.is_a?(Class) &&
98
+ actor.ancestors.map(&:name).include?("Interactor")
99
+ play_interactor(actor)
100
+ else
96
101
  actor.call(result)
102
+ end
97
103
  end
98
104
 
99
105
  def play_service_actor(actor)
100
- return unless actor.is_a?(Class)
101
- return unless actor.ancestors.include?(ServiceActor::Core)
102
-
103
106
  actor = actor.new(result)
104
107
  call_output = actor._call
105
108
 
@@ -109,16 +112,10 @@ module ServiceActor::Playable
109
112
  end
110
113
 
111
114
  def play_method(actor)
112
- return unless actor.is_a?(Symbol)
113
-
114
- # return truthy method value, or true as fallback
115
- send(actor) || true
115
+ send(actor)
116
116
  end
117
117
 
118
118
  def play_interactor(actor)
119
- return unless actor.is_a?(Class)
120
- return unless actor.ancestors.map(&:name).include?("Interactor")
121
-
122
119
  result.merge!(actor.call(result.to_h).to_h)
123
120
  end
124
121
  end
@@ -12,21 +12,25 @@ class ServiceActor::Result < BasicObject
12
12
  end
13
13
 
14
14
  %i[
15
+ block_given?
15
16
  class
17
+ instance_variables
16
18
  is_a?
17
19
  kind_of?
18
- send
20
+ nil?
21
+ object_id
22
+ private_methods
19
23
  public_send
24
+ send
20
25
  tap
21
26
  then
22
- block_given?
23
- object_id
24
- instance_variables
27
+ methods
25
28
  ].each do |method_name|
26
29
  define_method(method_name, ::Kernel.instance_method(method_name))
27
30
  end
28
31
 
29
32
  alias_method :yield_self, :then
33
+ alias_method :blank?, :nil?
30
34
 
31
35
  def initialize(data = {})
32
36
  @data = data.to_h
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ServiceActor
4
- VERSION = "3.9.0"
4
+ VERSION = "3.9.2"
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.0
4
+ version: 3.9.2
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-04-21 00:00:00.000000000 Z
11
+ date: 2024-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk