smart_core 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.travis.yml +3 -3
- data/CHANGELOG.md +3 -0
- data/Gemfile +0 -3
- data/README.md +5 -33
- data/Rakefile +2 -0
- data/lib/smart_core/container/command_definer.rb +117 -0
- data/lib/smart_core/container/command_set.rb +82 -0
- data/lib/smart_core/container/commands/base.rb +12 -0
- data/lib/smart_core/container/commands/namespace.rb +53 -0
- data/lib/smart_core/container/commands/register.rb +63 -0
- data/lib/smart_core/container/commands.rb +9 -0
- data/lib/smart_core/container/definition_dsl.rb +66 -0
- data/lib/smart_core/container/dependency.rb +44 -0
- data/lib/smart_core/container/dependency_builder.rb +48 -0
- data/lib/smart_core/container/dependency_compatability/abstract.rb +59 -0
- data/lib/smart_core/container/dependency_compatability/command_set.rb +35 -0
- data/lib/smart_core/container/dependency_compatability/registry.rb +37 -0
- data/lib/smart_core/container/dependency_compatability.rb +9 -0
- data/lib/smart_core/container/dependency_resolver.rb +16 -0
- data/lib/smart_core/container/entity.rb +26 -0
- data/lib/smart_core/container/exceptions.rb +31 -0
- data/lib/smart_core/container/key_guard.rb +31 -0
- data/lib/smart_core/container/memoized_dependency.rb +28 -0
- data/lib/smart_core/container/mixin.rb +82 -0
- data/lib/smart_core/container/namespace.rb +51 -0
- data/lib/smart_core/container/registry.rb +227 -0
- data/lib/smart_core/container/registry_builder.rb +18 -0
- data/lib/smart_core/container.rb +123 -0
- data/lib/smart_core/exceptions.rb +23 -0
- data/lib/smart_core/initializer/attribute/builder.rb +99 -0
- data/lib/smart_core/initializer/attribute/value_finalizer/lambda.rb +32 -0
- data/lib/smart_core/initializer/attribute/value_finalizer/method.rb +32 -0
- data/lib/smart_core/initializer/attribute/value_finalizer.rb +24 -0
- data/lib/smart_core/initializer/attribute.rb +123 -0
- data/lib/smart_core/initializer/attribute_definer.rb +162 -0
- data/lib/smart_core/{operation → initializer}/attribute_set.rb +17 -17
- data/lib/smart_core/initializer/exceptions.rb +47 -0
- data/lib/smart_core/initializer/extension.rb +39 -0
- data/lib/smart_core/initializer/extension_definer.rb +62 -0
- data/lib/smart_core/initializer/extension_set.rb +75 -0
- data/lib/smart_core/{operation → initializer}/initialization_dsl.rb +82 -42
- data/lib/smart_core/initializer/instance_attribute_accessing.rb +49 -0
- data/lib/smart_core/initializer/instance_builder.rb +164 -0
- data/lib/smart_core/initializer/type.rb +49 -0
- data/lib/smart_core/initializer/type_set.rb +52 -0
- data/lib/smart_core/initializer.rb +89 -0
- data/lib/smart_core/injector.rb +6 -0
- data/lib/smart_core/operation/exceptions.rb +4 -20
- data/lib/smart_core/operation/instance_builder.rb +16 -124
- data/lib/smart_core/operation/state.rb +7 -0
- data/lib/smart_core/operation/step.rb +43 -0
- data/lib/smart_core/operation/step_set.rb +73 -0
- data/lib/smart_core/operation/success.rb +11 -0
- data/lib/smart_core/operation.rb +10 -12
- data/lib/smart_core/schema.rb +6 -0
- data/lib/smart_core/validator/commands.rb +2 -0
- data/lib/smart_core/validator/exceptions.rb +1 -1
- data/lib/smart_core/version.rb +1 -1
- data/lib/smart_core.rb +5 -0
- data/smart_core.gemspec +14 -14
- metadata +57 -15
- data/lib/smart_core/operation/attribute.rb +0 -66
- data/lib/smart_core/operation/attribute_definer.rb +0 -160
@@ -23,6 +23,17 @@ class SmartCore::Operation::Success < SmartCore::Operation::Result
|
|
23
23
|
true.tap { yield(self) if block_given? }
|
24
24
|
end
|
25
25
|
|
26
|
+
# Support for operations like `result.success? { |**result| ...result-as-a-hash... }`
|
27
|
+
#
|
28
|
+
# @return [Hash]
|
29
|
+
#
|
30
|
+
# @api public
|
31
|
+
# @since 0.5.0
|
32
|
+
def to_h
|
33
|
+
__result_options__.dup
|
34
|
+
end
|
35
|
+
alias_method :to_hash, :to_h
|
36
|
+
|
26
37
|
private
|
27
38
|
|
28
39
|
# @param result_options [Hash<Symbol,Any>]
|
data/lib/smart_core/operation.rb
CHANGED
@@ -4,18 +4,22 @@
|
|
4
4
|
# @since 0.2.0
|
5
5
|
class SmartCore::Operation
|
6
6
|
require_relative 'operation/exceptions'
|
7
|
-
require_relative 'operation/
|
8
|
-
require_relative 'operation/
|
7
|
+
require_relative 'operation/state'
|
8
|
+
require_relative 'operation/step'
|
9
|
+
require_relative 'operation/step_set'
|
9
10
|
require_relative 'operation/result'
|
10
11
|
require_relative 'operation/success'
|
11
12
|
require_relative 'operation/failure'
|
12
13
|
require_relative 'operation/fatal'
|
13
14
|
require_relative 'operation/instance_builder'
|
14
|
-
require_relative 'operation/attribute_definer'
|
15
|
-
require_relative 'operation/initialization_dsl'
|
16
15
|
|
17
|
-
# @since 0.
|
18
|
-
include
|
16
|
+
# @since 0.5.0
|
17
|
+
include SmartCore::Initializer
|
18
|
+
|
19
|
+
# @since 0.5.0
|
20
|
+
extend_initialization_flow do |operation|
|
21
|
+
SmartCore::Operation::InstanceBuilder.call(operation)
|
22
|
+
end
|
19
23
|
|
20
24
|
class << self
|
21
25
|
# @param arguments [Any]
|
@@ -32,12 +36,6 @@ class SmartCore::Operation
|
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
|
-
# @return [void]
|
36
|
-
#
|
37
|
-
# @api private
|
38
|
-
# @since 0.2.0
|
39
|
-
def initialize(*, **); end
|
40
|
-
|
41
39
|
# @return [SmartCore::Operation::Success]
|
42
40
|
# @return [SmartCore::Operation::Failure]
|
43
41
|
# @return [SmartCore::Operation::Fatal]
|
data/lib/smart_core/version.rb
CHANGED
data/lib/smart_core.rb
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
# @since 0.1.0
|
5
5
|
module SmartCore
|
6
6
|
require_relative 'smart_core/version'
|
7
|
+
require_relative 'smart_core/exceptions'
|
8
|
+
require_relative 'smart_core/initializer'
|
9
|
+
require_relative 'smart_core/container'
|
10
|
+
require_relative 'smart_core/injector'
|
7
11
|
require_relative 'smart_core/validator'
|
8
12
|
require_relative 'smart_core/operation'
|
13
|
+
require_relative 'smart_core/schema'
|
9
14
|
end
|
data/smart_core.gemspec
CHANGED
@@ -7,27 +7,27 @@ require 'smart_core/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.required_ruby_version = '>= 2.3.8'
|
9
9
|
|
10
|
-
spec.name
|
11
|
-
spec.version
|
12
|
-
spec.authors
|
13
|
-
spec.email
|
14
|
-
spec.summary
|
15
|
-
spec.description
|
16
|
-
spec.homepage
|
17
|
-
spec.license
|
10
|
+
spec.name = 'smart_core'
|
11
|
+
spec.version = SmartCore::VERSION
|
12
|
+
spec.authors = ['Rustam Ibragimov']
|
13
|
+
spec.email = ['iamdaiver@icloud.com']
|
14
|
+
spec.summary = '(in active development) A set of common abstractions'
|
15
|
+
spec.description = '(in active development) A set of common abstractions'
|
16
|
+
spec.homepage = 'https://github.com/0exp/smart_core'
|
17
|
+
spec.license = 'MIT'
|
18
18
|
|
19
|
-
spec.bindir
|
20
|
-
spec.executables
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
|
25
25
|
end
|
26
26
|
|
27
|
-
spec.add_development_dependency 'coveralls', '~> 0.8
|
28
|
-
spec.add_development_dependency 'simplecov', '~> 0.16
|
29
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 0.
|
30
|
-
spec.add_development_dependency 'rspec', '~> 3.8
|
27
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
28
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
29
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 0.70'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler'
|
33
33
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.8
|
19
|
+
version: '0.8'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.8
|
26
|
+
version: '0.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.16
|
33
|
+
version: '0.16'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.16
|
40
|
+
version: '0.16'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: armitage-rubocop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: '0.70'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: '0.70'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.8
|
61
|
+
version: '3.8'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.8
|
68
|
+
version: '3.8'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,17 +128,59 @@ files:
|
|
128
128
|
- bin/console
|
129
129
|
- bin/setup
|
130
130
|
- lib/smart_core.rb
|
131
|
+
- lib/smart_core/container.rb
|
132
|
+
- lib/smart_core/container/command_definer.rb
|
133
|
+
- lib/smart_core/container/command_set.rb
|
134
|
+
- lib/smart_core/container/commands.rb
|
135
|
+
- lib/smart_core/container/commands/base.rb
|
136
|
+
- lib/smart_core/container/commands/namespace.rb
|
137
|
+
- lib/smart_core/container/commands/register.rb
|
138
|
+
- lib/smart_core/container/definition_dsl.rb
|
139
|
+
- lib/smart_core/container/dependency.rb
|
140
|
+
- lib/smart_core/container/dependency_builder.rb
|
141
|
+
- lib/smart_core/container/dependency_compatability.rb
|
142
|
+
- lib/smart_core/container/dependency_compatability/abstract.rb
|
143
|
+
- lib/smart_core/container/dependency_compatability/command_set.rb
|
144
|
+
- lib/smart_core/container/dependency_compatability/registry.rb
|
145
|
+
- lib/smart_core/container/dependency_resolver.rb
|
146
|
+
- lib/smart_core/container/entity.rb
|
147
|
+
- lib/smart_core/container/exceptions.rb
|
148
|
+
- lib/smart_core/container/key_guard.rb
|
149
|
+
- lib/smart_core/container/memoized_dependency.rb
|
150
|
+
- lib/smart_core/container/mixin.rb
|
151
|
+
- lib/smart_core/container/namespace.rb
|
152
|
+
- lib/smart_core/container/registry.rb
|
153
|
+
- lib/smart_core/container/registry_builder.rb
|
154
|
+
- lib/smart_core/exceptions.rb
|
155
|
+
- lib/smart_core/initializer.rb
|
156
|
+
- lib/smart_core/initializer/attribute.rb
|
157
|
+
- lib/smart_core/initializer/attribute/builder.rb
|
158
|
+
- lib/smart_core/initializer/attribute/value_finalizer.rb
|
159
|
+
- lib/smart_core/initializer/attribute/value_finalizer/lambda.rb
|
160
|
+
- lib/smart_core/initializer/attribute/value_finalizer/method.rb
|
161
|
+
- lib/smart_core/initializer/attribute_definer.rb
|
162
|
+
- lib/smart_core/initializer/attribute_set.rb
|
163
|
+
- lib/smart_core/initializer/exceptions.rb
|
164
|
+
- lib/smart_core/initializer/extension.rb
|
165
|
+
- lib/smart_core/initializer/extension_definer.rb
|
166
|
+
- lib/smart_core/initializer/extension_set.rb
|
167
|
+
- lib/smart_core/initializer/initialization_dsl.rb
|
168
|
+
- lib/smart_core/initializer/instance_attribute_accessing.rb
|
169
|
+
- lib/smart_core/initializer/instance_builder.rb
|
170
|
+
- lib/smart_core/initializer/type.rb
|
171
|
+
- lib/smart_core/initializer/type_set.rb
|
172
|
+
- lib/smart_core/injector.rb
|
131
173
|
- lib/smart_core/operation.rb
|
132
|
-
- lib/smart_core/operation/attribute.rb
|
133
|
-
- lib/smart_core/operation/attribute_definer.rb
|
134
|
-
- lib/smart_core/operation/attribute_set.rb
|
135
174
|
- lib/smart_core/operation/exceptions.rb
|
136
175
|
- lib/smart_core/operation/failure.rb
|
137
176
|
- lib/smart_core/operation/fatal.rb
|
138
|
-
- lib/smart_core/operation/initialization_dsl.rb
|
139
177
|
- lib/smart_core/operation/instance_builder.rb
|
140
178
|
- lib/smart_core/operation/result.rb
|
179
|
+
- lib/smart_core/operation/state.rb
|
180
|
+
- lib/smart_core/operation/step.rb
|
181
|
+
- lib/smart_core/operation/step_set.rb
|
141
182
|
- lib/smart_core/operation/success.rb
|
183
|
+
- lib/smart_core/schema.rb
|
142
184
|
- lib/smart_core/validator.rb
|
143
185
|
- lib/smart_core/validator/attribute.rb
|
144
186
|
- lib/smart_core/validator/attribute_set.rb
|
@@ -175,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
217
|
- !ruby/object:Gem::Version
|
176
218
|
version: '0'
|
177
219
|
requirements: []
|
178
|
-
rubygems_version: 3.0.
|
220
|
+
rubygems_version: 3.0.3
|
179
221
|
signing_key:
|
180
222
|
specification_version: 4
|
181
223
|
summary: "(in active development) A set of common abstractions"
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# @api private
|
4
|
-
# @since 0.2.0
|
5
|
-
class SmartCore::Operation::Attribute
|
6
|
-
# @return [Symbol]
|
7
|
-
#
|
8
|
-
# @api private
|
9
|
-
# @since 0.2.0
|
10
|
-
attr_reader :name
|
11
|
-
|
12
|
-
# @return [Hash<Symbol,Any>]
|
13
|
-
#
|
14
|
-
# @api private
|
15
|
-
# @since 0.2.0
|
16
|
-
attr_reader :options
|
17
|
-
|
18
|
-
# @param name [String, Symbol]
|
19
|
-
# @param options [Hash<Symbol,Any>] Supported options:
|
20
|
-
# - :default (see #default_value) (proc or object)
|
21
|
-
# @return [void]
|
22
|
-
#
|
23
|
-
# @api private
|
24
|
-
# @since 0.2.0
|
25
|
-
def initialize(name, **options)
|
26
|
-
unless name.is_a?(Symbol) || name.is_a?(String)
|
27
|
-
raise(
|
28
|
-
SmartCore::Operation::IncorrectAttributeNameError,
|
29
|
-
'Attribute name should be a symbol or a string'
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
@name = name
|
34
|
-
@options = options # TODO: check for unsupported options (and fail if found)
|
35
|
-
end
|
36
|
-
|
37
|
-
# @return [Boolean]
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
# @since 0.2.0
|
41
|
-
def has_default_value?
|
42
|
-
options.key?(:default)
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [Any]
|
46
|
-
#
|
47
|
-
# @raise [SmartCore::Operation::ArgumentError]
|
48
|
-
#
|
49
|
-
# @api private
|
50
|
-
# @since 0.2.0
|
51
|
-
def default_value
|
52
|
-
default_value = options.fetch(:default) do
|
53
|
-
raise(SmartCore::Operation::ArgumentError, 'Default value is not provided.')
|
54
|
-
end
|
55
|
-
|
56
|
-
default_value.is_a?(Proc) ? default_value.call : default_value
|
57
|
-
end
|
58
|
-
|
59
|
-
# @return [SmartCore::Operation::Attribute]
|
60
|
-
#
|
61
|
-
# @api private
|
62
|
-
# @since 0.2.0
|
63
|
-
def dup
|
64
|
-
self.class.new(name, **options)
|
65
|
-
end
|
66
|
-
end
|
@@ -1,160 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# @api private
|
4
|
-
# @since 0.2.0
|
5
|
-
class SmartCore::Operation::AttributeDefiner
|
6
|
-
# @param operation_klass [Class<SmartCore::Operation>]
|
7
|
-
# @return [void]
|
8
|
-
#
|
9
|
-
# @api private
|
10
|
-
# @since 0.2.0
|
11
|
-
def initialize(operation_klass)
|
12
|
-
@operation_klass = operation_klass
|
13
|
-
@definition_lock = Mutex.new
|
14
|
-
end
|
15
|
-
|
16
|
-
# @param param_name [Symbol, String]
|
17
|
-
# @return [void]
|
18
|
-
#
|
19
|
-
# @api private
|
20
|
-
# @since 0.2.0
|
21
|
-
def define_param(param_name)
|
22
|
-
thread_safe do
|
23
|
-
parameter = build_attribute(param_name)
|
24
|
-
prevent_intersection_with_already_defined_option(parameter)
|
25
|
-
append_parameter(parameter)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# @param param_names [Array<String, Symbol>]
|
30
|
-
# @return [void]
|
31
|
-
#
|
32
|
-
# @api private
|
33
|
-
# @since 0.2.0
|
34
|
-
def define_params(*param_names)
|
35
|
-
thread_safe do
|
36
|
-
parameters = param_names.map do |param_name|
|
37
|
-
build_attribute(param_name).tap do |parameter|
|
38
|
-
prevent_intersection_with_already_defined_option(parameter)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
parameters.each { |parameter| append_parameter(parameter) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# @param option_name [Symbol, String]
|
47
|
-
# @return [void]
|
48
|
-
#
|
49
|
-
# @api private
|
50
|
-
# @since 0.2.0
|
51
|
-
def define_option(option_name, **options)
|
52
|
-
thread_safe do
|
53
|
-
option = build_attribute(option_name, **options)
|
54
|
-
prevent_intersection_with_already_defined_param(option)
|
55
|
-
append_option(option)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# @param option_names [Array<String, Symbol>]
|
60
|
-
# @return [void]
|
61
|
-
#
|
62
|
-
# @api private
|
63
|
-
# @since 0.2.0
|
64
|
-
def define_options(*option_names)
|
65
|
-
thread_safe do
|
66
|
-
options = option_names.map do |option_name|
|
67
|
-
build_attribute(option_name).tap do |option|
|
68
|
-
prevent_intersection_with_already_defined_param(option)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
options.each { |option| append_option(option) }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
# @return [Class<SmartCore::Operation>]
|
79
|
-
#
|
80
|
-
# @api private
|
81
|
-
# @since 0.2.0
|
82
|
-
attr_reader :operation_klass
|
83
|
-
|
84
|
-
# @return [Mutex]
|
85
|
-
#
|
86
|
-
# @api private
|
87
|
-
# @since 0.2.0
|
88
|
-
attr_reader :definition_lock
|
89
|
-
|
90
|
-
# @param attribute_name [Symbol, String]
|
91
|
-
# @param attribute_options [Hash<Symbol,Any>]
|
92
|
-
# @return [SmartCore::Operation::Attribute]
|
93
|
-
#
|
94
|
-
# @api private
|
95
|
-
# @since 0.2.0
|
96
|
-
def build_attribute(attribute_name, **attribute_options)
|
97
|
-
SmartCore::Operation::Attribute.new(attribute_name, **attribute_options)
|
98
|
-
end
|
99
|
-
|
100
|
-
# @param parameter [SmartCore::Operation::Attribute]
|
101
|
-
# @return [void]
|
102
|
-
#
|
103
|
-
# @api private
|
104
|
-
# @since 0.2.0
|
105
|
-
def append_parameter(parameter)
|
106
|
-
operation_klass.__params__ << parameter
|
107
|
-
operation_klass.send(:attr_reader, parameter.name)
|
108
|
-
end
|
109
|
-
|
110
|
-
# @param option [SmartCore::Operation::Attribute]
|
111
|
-
# @return [void]
|
112
|
-
#
|
113
|
-
# @api private
|
114
|
-
# @since 0.2.0
|
115
|
-
def append_option(option)
|
116
|
-
operation_klass.__options__ << option
|
117
|
-
operation_klass.send(:attr_reader, option.name)
|
118
|
-
end
|
119
|
-
|
120
|
-
# @param parameter [SmartCore::Operation::Attribute]
|
121
|
-
# @return [void]
|
122
|
-
#
|
123
|
-
# @raise [SmartCore::Operation::OptionOverlapError]
|
124
|
-
#
|
125
|
-
# @api private
|
126
|
-
# @since 0.2.0
|
127
|
-
def prevent_intersection_with_already_defined_option(parameter)
|
128
|
-
if operation_klass.__options__.conflicts_with?(parameter)
|
129
|
-
raise(
|
130
|
-
SmartCore::Operation::OptionOverlapError,
|
131
|
-
"You have already defined option with :#{parameter.name} name"
|
132
|
-
)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
# @param option [SmartCore::Operation::Attribute]
|
137
|
-
# @return [void]
|
138
|
-
#
|
139
|
-
# @raise [SmartCore::Operation::ParamOverlapError]
|
140
|
-
#
|
141
|
-
# @api private
|
142
|
-
# @since 0.2.0
|
143
|
-
def prevent_intersection_with_already_defined_param(option)
|
144
|
-
if operation_klass.__params__.conflicts_with?(option)
|
145
|
-
raise(
|
146
|
-
SmartCore::Operation::ParamOverlapError,
|
147
|
-
"You have already defined param with :#{option.name} name"
|
148
|
-
)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
# @param block [Proc]
|
153
|
-
# @return [Any]
|
154
|
-
#
|
155
|
-
# @api private
|
156
|
-
# @since 0.2.0
|
157
|
-
def thread_safe(&block)
|
158
|
-
definition_lock.synchronize(&block)
|
159
|
-
end
|
160
|
-
end
|