servactory 2.8.0 → 2.9.0.rc1

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: 2fd2afd31c63b79469991b78c2c30728aa2d268eeaf9deac3ea0e72c06db6614
4
- data.tar.gz: e11af49a2bc836b3f265c4dc48957106550b905c05682cb837099ed53a62c24a
3
+ metadata.gz: ca75399cdb14c4dc3b28703e9c3b2baf353f0612d8414de865f780a69dc56e74
4
+ data.tar.gz: 74c08748d40a6233942c5c4b0b34f7b0ccb0a63776468d98ea08fda660b826fd
5
5
  SHA512:
6
- metadata.gz: 7d22e4e63465bcc22943d6eb90085081ba299ea571cea5393fabc22dae15d434e05b51f78f7fd26d27d93d3775419d89c24a47c492c2a8808565e5a8d6f0bfc4
7
- data.tar.gz: cb529f9e8c66ef9de222ae4a66b0884635f1dda2435020a67d024c61686f6ffa1434e80b773e71a66c84776e55e305240bbc4e26c5cd4cfc22b5483500b8bff7
6
+ metadata.gz: f48fd065703fde42c80f14dae2045ea1af0c31d66c5eece2ccd4cb94358c089d7ca4e59417588a6f40dbd77376786377ad4ef90285f4d6a545925d5ecc0f0f8e
7
+ data.tar.gz: c495107855b7a1939717457638e7171ef1deb9f979426dbdc5084c84ecc78b87bc38688a71df458a9afc5ee5befe7141c78122f7f071af00c5120ef15a0480a7
@@ -6,7 +6,7 @@ module Servactory
6
6
  def call!(arguments = {})
7
7
  context = send(:new)
8
8
 
9
- _call!(context, **arguments)
9
+ _call!(context, arguments)
10
10
 
11
11
  config.result_class.success_for(context:)
12
12
  rescue config.success_class => e
@@ -16,7 +16,7 @@ module Servactory
16
16
  def call(arguments = {})
17
17
  context = send(:new)
18
18
 
19
- _call!(context, **arguments)
19
+ _call!(context, arguments)
20
20
 
21
21
  config.result_class.success_for(context:)
22
22
  rescue config.success_class => e
@@ -27,10 +27,12 @@ module Servactory
27
27
 
28
28
  private
29
29
 
30
- def _call!(context, **arguments)
30
+ def _call!(context, incoming_arguments)
31
+ incoming_arguments = Servactory::Utils.adapt(incoming_arguments)
32
+
31
33
  context.send(
32
34
  :_call!,
33
- incoming_arguments: arguments.symbolize_keys,
35
+ incoming_arguments:,
34
36
  collection_of_inputs:,
35
37
  collection_of_internals:,
36
38
  collection_of_outputs:,
@@ -13,7 +13,7 @@ module Servactory
13
13
  @attribute_type = attribute_type
14
14
  @attribute_type_plural = attribute_type.to_s.pluralize.to_sym
15
15
  @attribute_name = attribute_name
16
- @attributes = attributes
16
+ @attributes = attributes.is_a?(FalseClass) ? attributes : Servactory::Utils.adapt(attributes)
17
17
 
18
18
  @attribute_data = described_class.info.public_send(attribute_type_plural).fetch(attribute_name)
19
19
 
@@ -2,7 +2,15 @@
2
2
 
3
3
  module Servactory
4
4
  module Utils
5
- module_function
5
+ extend self
6
+
7
+ def adapt(data)
8
+ if defined?(Datory::Base) && data.is_a?(Datory::Base)
9
+ data = Servactory::Utils.send(:instance_variables_to_hash_from, data)
10
+ end
11
+
12
+ data.symbolize_keys
13
+ end
6
14
 
7
15
  def fetch_hash_with_desired_attribute(attribute)
8
16
  return { input: attribute.class::Actor.new(attribute) } if really_input?(attribute)
@@ -97,5 +105,24 @@ module Servactory
97
105
  class_or_name
98
106
  end
99
107
  end
108
+
109
+ private
110
+
111
+ def instance_variables_to_hash_from(data) # rubocop:disable Metrics/MethodLength
112
+ data.instance_variables.to_h do |key|
113
+ value = data.instance_variable_get(key)
114
+
115
+ value =
116
+ if value.is_a?(Set) || value.is_a?(Array)
117
+ value.map { |item| instance_variables_to_hash_from(item) }
118
+ elsif value.is_a?(Datory::Base)
119
+ instance_variables_to_hash_from(value)
120
+ else
121
+ value
122
+ end
123
+
124
+ [key.to_s.delete_prefix("@"), value]
125
+ end
126
+ end
100
127
  end
101
128
  end
@@ -3,9 +3,9 @@
3
3
  module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 8
6
+ MINOR = 9
7
7
  PATCH = 0
8
- PRE = nil
8
+ PRE = "rc1"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-28 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.31'
89
+ - !ruby/object:Gem::Dependency
90
+ name: datory
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.1.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 2.1.0
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: pry
91
105
  requirement: !ruby/object:Gem::Requirement