servactory 1.5.2 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -394
- data/config/locales/en.yml +5 -5
- data/lib/servactory/base.rb +4 -4
- data/lib/servactory/configuration/factory.rb +10 -6
- data/lib/servactory/configuration/setup.rb +10 -7
- data/lib/servactory/context/callable.rb +21 -22
- data/lib/servactory/context/workspace/inputs.rb +13 -0
- data/lib/servactory/context/workspace.rb +9 -7
- data/lib/servactory/errors/base.rb +2 -1
- data/lib/servactory/errors/collection.rb +25 -0
- data/lib/servactory/errors/failure.rb +11 -1
- data/lib/servactory/errors/input_error.rb +17 -0
- data/lib/servactory/errors/internal_error.rb +15 -0
- data/lib/servactory/errors/output_error.rb +15 -0
- data/lib/servactory/{input_arguments → inputs}/checks/base.rb +3 -3
- data/lib/servactory/{input_arguments → inputs}/checks/errors.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/checks/inclusion.rb +2 -2
- data/lib/servactory/{input_arguments → inputs}/checks/must.rb +3 -3
- data/lib/servactory/{input_arguments → inputs}/checks/required.rb +2 -2
- data/lib/servactory/{input_arguments → inputs}/checks/type.rb +3 -3
- data/lib/servactory/{input_arguments → inputs}/collection.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/define_input_conflict.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/define_input_method.rb +1 -1
- data/lib/servactory/inputs/dsl.rb +36 -0
- data/lib/servactory/{input_arguments/input_argument.rb → inputs/input.rb} +12 -12
- data/lib/servactory/{input_arguments → inputs}/option.rb +5 -3
- data/lib/servactory/{input_arguments → inputs}/options_collection.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/tools/check.rb +5 -5
- data/lib/servactory/{input_arguments → inputs}/tools/check_errors.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/tools/find_unnecessary.rb +6 -6
- data/lib/servactory/{input_arguments → inputs}/tools/prepare.rb +5 -5
- data/lib/servactory/inputs/tools/rules.rb +46 -0
- data/lib/servactory/{input_arguments → inputs}/workbench.rb +8 -8
- data/lib/servactory/internals/checks/base.rb +17 -0
- data/lib/servactory/{internal_arguments → internals}/checks/type.rb +8 -8
- data/lib/servactory/{output_arguments → internals}/collection.rb +1 -1
- data/lib/servactory/internals/dsl.rb +33 -0
- data/lib/servactory/{internal_arguments/internal_argument.rb → internals/internal.rb} +2 -2
- data/lib/servactory/internals/tools/prepare.rb +60 -0
- data/lib/servactory/{internal_arguments → internals}/workbench.rb +5 -5
- data/lib/servactory/{make_methods → methods}/collection.rb +1 -1
- data/lib/servactory/methods/dsl.rb +47 -0
- data/lib/servactory/{make_methods/make_method.rb → methods/method.rb} +2 -2
- data/lib/servactory/methods/shortcuts/collection.rb +17 -0
- data/lib/servactory/{make_methods → methods}/workbench.rb +6 -6
- data/lib/servactory/outputs/checks/base.rb +17 -0
- data/lib/servactory/{output_arguments → outputs}/checks/type.rb +8 -8
- data/lib/servactory/{internal_arguments → outputs}/collection.rb +1 -1
- data/lib/servactory/outputs/dsl.rb +33 -0
- data/lib/servactory/{output_arguments/output_argument.rb → outputs/output.rb} +2 -2
- data/lib/servactory/{output_arguments → outputs}/tools/conflicts.rb +7 -7
- data/lib/servactory/outputs/tools/prepare.rb +62 -0
- data/lib/servactory/outputs/workbench.rb +31 -0
- data/lib/servactory/result.rb +4 -4
- data/lib/servactory/utils.rb +2 -0
- data/lib/servactory/version.rb +2 -2
- metadata +60 -47
- data/lib/servactory/context/configuration.rb +0 -23
- data/lib/servactory/context/workspace/error.rb +0 -19
- data/lib/servactory/context/workspace/errors.rb +0 -33
- data/lib/servactory/errors/input_argument_error.rb +0 -7
- data/lib/servactory/errors/internal_argument_error.rb +0 -7
- data/lib/servactory/errors/output_argument_error.rb +0 -7
- data/lib/servactory/input_arguments/dsl.rb +0 -36
- data/lib/servactory/input_arguments/tools/rules.rb +0 -43
- data/lib/servactory/inputs.rb +0 -9
- data/lib/servactory/internal_arguments/checks/base.rb +0 -17
- data/lib/servactory/internal_arguments/dsl.rb +0 -33
- data/lib/servactory/internal_arguments/tools/prepare.rb +0 -60
- data/lib/servactory/make_methods/dsl.rb +0 -33
- data/lib/servactory/output_arguments/checks/base.rb +0 -17
- data/lib/servactory/output_arguments/dsl.rb +0 -33
- data/lib/servactory/output_arguments/tools/prepare.rb +0 -62
- data/lib/servactory/output_arguments/workbench.rb +0 -31
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: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '2.19'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.9'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.9'
|
167
181
|
description: A set of tools for building reliable services of any complexity
|
168
182
|
email:
|
169
183
|
- profox.rus@gmail.com
|
@@ -180,57 +194,56 @@ files:
|
|
180
194
|
- lib/servactory/configuration/factory.rb
|
181
195
|
- lib/servactory/configuration/setup.rb
|
182
196
|
- lib/servactory/context/callable.rb
|
183
|
-
- lib/servactory/context/configuration.rb
|
184
197
|
- lib/servactory/context/dsl.rb
|
185
198
|
- lib/servactory/context/store.rb
|
186
199
|
- lib/servactory/context/workspace.rb
|
187
|
-
- lib/servactory/context/workspace/
|
188
|
-
- lib/servactory/context/workspace/errors.rb
|
200
|
+
- lib/servactory/context/workspace/inputs.rb
|
189
201
|
- lib/servactory/engine.rb
|
190
202
|
- lib/servactory/errors/base.rb
|
203
|
+
- lib/servactory/errors/collection.rb
|
191
204
|
- lib/servactory/errors/failure.rb
|
192
|
-
- lib/servactory/errors/
|
193
|
-
- lib/servactory/errors/
|
194
|
-
- lib/servactory/errors/
|
195
|
-
- lib/servactory/
|
196
|
-
- lib/servactory/
|
197
|
-
- lib/servactory/
|
198
|
-
- lib/servactory/
|
199
|
-
- lib/servactory/
|
200
|
-
- lib/servactory/
|
201
|
-
- lib/servactory/
|
202
|
-
- lib/servactory/
|
203
|
-
- lib/servactory/
|
204
|
-
- lib/servactory/
|
205
|
-
- lib/servactory/
|
206
|
-
- lib/servactory/
|
207
|
-
- lib/servactory/
|
208
|
-
- lib/servactory/
|
209
|
-
- lib/servactory/
|
210
|
-
- lib/servactory/
|
211
|
-
- lib/servactory/
|
212
|
-
- lib/servactory/
|
213
|
-
- lib/servactory/
|
214
|
-
- lib/servactory/
|
215
|
-
- lib/servactory/
|
216
|
-
- lib/servactory/
|
217
|
-
- lib/servactory/
|
218
|
-
- lib/servactory/
|
219
|
-
- lib/servactory/
|
220
|
-
- lib/servactory/
|
221
|
-
- lib/servactory/
|
222
|
-
- lib/servactory/
|
223
|
-
- lib/servactory/
|
224
|
-
- lib/servactory/
|
225
|
-
- lib/servactory/
|
226
|
-
- lib/servactory/
|
227
|
-
- lib/servactory/
|
228
|
-
- lib/servactory/
|
229
|
-
- lib/servactory/
|
230
|
-
- lib/servactory/
|
231
|
-
- lib/servactory/
|
232
|
-
- lib/servactory/
|
233
|
-
- lib/servactory/
|
205
|
+
- lib/servactory/errors/input_error.rb
|
206
|
+
- lib/servactory/errors/internal_error.rb
|
207
|
+
- lib/servactory/errors/output_error.rb
|
208
|
+
- lib/servactory/inputs/checks/base.rb
|
209
|
+
- lib/servactory/inputs/checks/errors.rb
|
210
|
+
- lib/servactory/inputs/checks/inclusion.rb
|
211
|
+
- lib/servactory/inputs/checks/must.rb
|
212
|
+
- lib/servactory/inputs/checks/required.rb
|
213
|
+
- lib/servactory/inputs/checks/type.rb
|
214
|
+
- lib/servactory/inputs/collection.rb
|
215
|
+
- lib/servactory/inputs/define_input_conflict.rb
|
216
|
+
- lib/servactory/inputs/define_input_method.rb
|
217
|
+
- lib/servactory/inputs/dsl.rb
|
218
|
+
- lib/servactory/inputs/input.rb
|
219
|
+
- lib/servactory/inputs/option.rb
|
220
|
+
- lib/servactory/inputs/options_collection.rb
|
221
|
+
- lib/servactory/inputs/tools/check.rb
|
222
|
+
- lib/servactory/inputs/tools/check_errors.rb
|
223
|
+
- lib/servactory/inputs/tools/find_unnecessary.rb
|
224
|
+
- lib/servactory/inputs/tools/prepare.rb
|
225
|
+
- lib/servactory/inputs/tools/rules.rb
|
226
|
+
- lib/servactory/inputs/workbench.rb
|
227
|
+
- lib/servactory/internals/checks/base.rb
|
228
|
+
- lib/servactory/internals/checks/type.rb
|
229
|
+
- lib/servactory/internals/collection.rb
|
230
|
+
- lib/servactory/internals/dsl.rb
|
231
|
+
- lib/servactory/internals/internal.rb
|
232
|
+
- lib/servactory/internals/tools/prepare.rb
|
233
|
+
- lib/servactory/internals/workbench.rb
|
234
|
+
- lib/servactory/methods/collection.rb
|
235
|
+
- lib/servactory/methods/dsl.rb
|
236
|
+
- lib/servactory/methods/method.rb
|
237
|
+
- lib/servactory/methods/shortcuts/collection.rb
|
238
|
+
- lib/servactory/methods/workbench.rb
|
239
|
+
- lib/servactory/outputs/checks/base.rb
|
240
|
+
- lib/servactory/outputs/checks/type.rb
|
241
|
+
- lib/servactory/outputs/collection.rb
|
242
|
+
- lib/servactory/outputs/dsl.rb
|
243
|
+
- lib/servactory/outputs/output.rb
|
244
|
+
- lib/servactory/outputs/tools/conflicts.rb
|
245
|
+
- lib/servactory/outputs/tools/prepare.rb
|
246
|
+
- lib/servactory/outputs/workbench.rb
|
234
247
|
- lib/servactory/result.rb
|
235
248
|
- lib/servactory/utils.rb
|
236
249
|
- lib/servactory/version.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Context
|
5
|
-
class Configuration
|
6
|
-
def input_argument_error_class(input_argument_error_class)
|
7
|
-
Servactory.configuration.input_argument_error_class = input_argument_error_class
|
8
|
-
end
|
9
|
-
|
10
|
-
def output_argument_error_class(output_argument_error_class)
|
11
|
-
Servactory.configuration.output_argument_error_class = output_argument_error_class
|
12
|
-
end
|
13
|
-
|
14
|
-
def internal_argument_error_class(internal_argument_error_class)
|
15
|
-
Servactory.configuration.internal_argument_error_class = internal_argument_error_class
|
16
|
-
end
|
17
|
-
|
18
|
-
def failure_class(failure_class)
|
19
|
-
Servactory.configuration.failure_class = failure_class
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Context
|
5
|
-
module Workspace
|
6
|
-
class Error
|
7
|
-
attr_reader :type,
|
8
|
-
:message,
|
9
|
-
:attribute_name
|
10
|
-
|
11
|
-
def initialize(type:, message:, attribute_name: nil)
|
12
|
-
@type = type
|
13
|
-
@message = message
|
14
|
-
@attribute_name = attribute_name
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Context
|
5
|
-
module Workspace
|
6
|
-
class Errors
|
7
|
-
# NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
|
8
|
-
extend Forwardable
|
9
|
-
def_delegators :@collection, :<<, :to_a, :filter, :reject, :empty?, :first
|
10
|
-
|
11
|
-
def initialize(collection = Set.new)
|
12
|
-
@collection = collection
|
13
|
-
end
|
14
|
-
|
15
|
-
def not_blank
|
16
|
-
Errors.new(reject(&:blank?))
|
17
|
-
end
|
18
|
-
|
19
|
-
def for_fails
|
20
|
-
filtered = filter { |error| error.type == :fail }
|
21
|
-
|
22
|
-
Errors.new(filtered)
|
23
|
-
end
|
24
|
-
|
25
|
-
def for_inputs
|
26
|
-
filtered = filter { |error| error.type == :inputs }
|
27
|
-
|
28
|
-
Errors.new(filtered)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InputArguments
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_input_arguments).merge(collection_of_input_arguments)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def input(name, **options)
|
20
|
-
collection_of_input_arguments << InputArgument.new(
|
21
|
-
name,
|
22
|
-
**options
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
def collection_of_input_arguments
|
27
|
-
@collection_of_input_arguments ||= Collection.new
|
28
|
-
end
|
29
|
-
|
30
|
-
def input_arguments_workbench
|
31
|
-
@input_arguments_workbench ||= Workbench.work_with(collection_of_input_arguments)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InputArguments
|
5
|
-
module Tools
|
6
|
-
class Rules
|
7
|
-
def self.check!(...)
|
8
|
-
new(...).check!
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_input_arguments)
|
12
|
-
@context = context
|
13
|
-
@collection_of_input_arguments = collection_of_input_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
def check!
|
17
|
-
@collection_of_input_arguments.each do |input_argument|
|
18
|
-
check_for!(input_argument)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def check_for!(input_argument)
|
25
|
-
return unless input_argument.with_conflicts?
|
26
|
-
|
27
|
-
raise_error_for(input_argument)
|
28
|
-
end
|
29
|
-
|
30
|
-
def raise_error_for(input_argument)
|
31
|
-
message_text = I18n.t(
|
32
|
-
"servactory.input_arguments.tools.rules.error",
|
33
|
-
service_class_name: @context.class.name,
|
34
|
-
input_name: input_argument.name,
|
35
|
-
conflict_code: input_argument.conflict_code
|
36
|
-
)
|
37
|
-
|
38
|
-
raise Servactory.configuration.input_argument_error_class, message_text
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/servactory/inputs.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InternalArguments
|
5
|
-
module Checks
|
6
|
-
class Base
|
7
|
-
protected
|
8
|
-
|
9
|
-
def raise_error_with(message, **arguments)
|
10
|
-
message = message.call(**arguments) if message.is_a?(Proc)
|
11
|
-
|
12
|
-
raise Servactory.configuration.internal_argument_error_class, message
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InternalArguments
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_internal_arguments).merge(collection_of_internal_arguments)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def internal(name, **options)
|
20
|
-
collection_of_internal_arguments << InternalArgument.new(name, **options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def collection_of_internal_arguments
|
24
|
-
@collection_of_internal_arguments ||= Collection.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def internal_arguments_workbench
|
28
|
-
@internal_arguments_workbench ||= Workbench.work_with(collection_of_internal_arguments)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InternalArguments
|
5
|
-
module Tools
|
6
|
-
class Prepare
|
7
|
-
def self.prepare(...)
|
8
|
-
new(...).prepare
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_internal_arguments)
|
12
|
-
@context = context
|
13
|
-
@collection_of_internal_arguments = collection_of_internal_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
def prepare
|
17
|
-
@collection_of_internal_arguments.each do |internal_argument|
|
18
|
-
create_instance_variable_for(internal_argument)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def create_instance_variable_for(internal_argument)
|
25
|
-
@context.instance_variable_set(:"@#{internal_argument.name}", nil)
|
26
|
-
|
27
|
-
@context.class.class_eval(context_internal_argument_template_for(internal_argument))
|
28
|
-
end
|
29
|
-
|
30
|
-
# EXAMPLE:
|
31
|
-
#
|
32
|
-
# define_method(:user=) do |value|
|
33
|
-
# Servactory::InternalArguments::Checks::Type.check!( context: self, internal_argument:, value: )
|
34
|
-
#
|
35
|
-
# instance_variable_set(:@user, value)
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# private attr_reader :user
|
39
|
-
#
|
40
|
-
def context_internal_argument_template_for(internal_argument)
|
41
|
-
<<-RUBY
|
42
|
-
define_method(:#{internal_argument.name}=) do |value|
|
43
|
-
Servactory::InternalArguments::Checks::Type.check!(
|
44
|
-
context: self,
|
45
|
-
internal_argument: internal_argument,
|
46
|
-
value: value
|
47
|
-
)
|
48
|
-
|
49
|
-
instance_variable_set(:@#{internal_argument.name}, value)
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
attr_reader :#{internal_argument.name}
|
55
|
-
RUBY
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module MakeMethods
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_make_methods).merge(collection_of_make_methods)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def make(name, **options)
|
20
|
-
collection_of_make_methods << MakeMethod.new(name, **options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def collection_of_make_methods
|
24
|
-
@collection_of_make_methods ||= Collection.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def make_methods_workbench
|
28
|
-
@make_methods_workbench ||= Workbench.work_with(collection_of_make_methods)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
module Checks
|
6
|
-
class Base
|
7
|
-
protected
|
8
|
-
|
9
|
-
def raise_error_with(message, **arguments)
|
10
|
-
message = message.call(**arguments) if message.is_a?(Proc)
|
11
|
-
|
12
|
-
raise Servactory.configuration.output_argument_error_class, message
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_output_arguments).merge(collection_of_output_arguments)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def output(name, **options)
|
20
|
-
collection_of_output_arguments << OutputArgument.new(name, **options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def collection_of_output_arguments
|
24
|
-
@collection_of_output_arguments ||= Collection.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def output_arguments_workbench
|
28
|
-
@output_arguments_workbench ||= Workbench.work_with(collection_of_output_arguments)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
module Tools
|
6
|
-
class Prepare
|
7
|
-
def self.prepare(...)
|
8
|
-
new(...).prepare
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_output_arguments)
|
12
|
-
@context = context
|
13
|
-
@collection_of_output_arguments = collection_of_output_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
def prepare
|
17
|
-
@collection_of_output_arguments.each do |output_argument|
|
18
|
-
create_instance_variable_for(output_argument)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def create_instance_variable_for(output_argument)
|
25
|
-
@context.instance_variable_set(:"@#{output_argument.name}", nil)
|
26
|
-
|
27
|
-
@context.class.class_eval(context_output_argument_template_for(output_argument))
|
28
|
-
end
|
29
|
-
|
30
|
-
# EXAMPLE:
|
31
|
-
#
|
32
|
-
# define_method(:user=) do |value|
|
33
|
-
# Servactory::InternalArguments::Checks::Type.check!( context: self, output_argument:, value: )
|
34
|
-
#
|
35
|
-
# instance_variable_set(:@user, value)
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# private
|
39
|
-
#
|
40
|
-
# attr_reader :user
|
41
|
-
#
|
42
|
-
def context_output_argument_template_for(output_argument)
|
43
|
-
<<-RUBY
|
44
|
-
define_method(:#{output_argument.name}=) do |value|
|
45
|
-
Servactory::OutputArguments::Checks::Type.check!(
|
46
|
-
context: self,
|
47
|
-
output_argument: output_argument,
|
48
|
-
value: value
|
49
|
-
)
|
50
|
-
|
51
|
-
instance_variable_set(:@#{output_argument.name}, value)
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
attr_reader :#{output_argument.name}
|
57
|
-
RUBY
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
class Workbench
|
6
|
-
def self.work_with(...)
|
7
|
-
new(...)
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(collection_of_output_arguments)
|
11
|
-
@collection_of_output_arguments = collection_of_output_arguments
|
12
|
-
end
|
13
|
-
|
14
|
-
def assign(context:)
|
15
|
-
@context = context
|
16
|
-
end
|
17
|
-
|
18
|
-
def find_conflicts_in!(collection_of_internal_arguments:)
|
19
|
-
Tools::Conflicts.check!(context, collection_of_output_arguments, collection_of_internal_arguments)
|
20
|
-
end
|
21
|
-
|
22
|
-
def prepare
|
23
|
-
Tools::Prepare.prepare(context, collection_of_output_arguments)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :context, :collection_of_output_arguments
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|