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
@@ -1,58 +1,58 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# @api private
|
4
|
-
# @since 0.
|
5
|
-
class SmartCore::
|
6
|
-
# @since 0.
|
4
|
+
# @since 0.5.0
|
5
|
+
class SmartCore::Initializer::AttributeSet
|
6
|
+
# @since 0.5.0
|
7
7
|
include Enumerable
|
8
8
|
|
9
|
-
# @return [Hash<Symbol, SmartCore::
|
9
|
+
# @return [Hash<Symbol, SmartCore::Initializer::Attribute>]
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
-
# @since 0.
|
12
|
+
# @since 0.5.0
|
13
13
|
attr_reader :attributes
|
14
14
|
|
15
15
|
# @return [void]
|
16
16
|
#
|
17
17
|
# @api private
|
18
|
-
# @since 0.
|
18
|
+
# @since 0.5.0
|
19
19
|
def initialize
|
20
20
|
@attributes = {}
|
21
21
|
@access_lock = Mutex.new
|
22
22
|
end
|
23
23
|
|
24
|
-
# @param attribute [SmartCore::
|
24
|
+
# @param attribute [SmartCore::Initializer::Attribute]
|
25
25
|
# @return [void]
|
26
26
|
#
|
27
27
|
# @api private
|
28
|
-
# @since 0.
|
28
|
+
# @since 0.5.0
|
29
29
|
def add_attribute(attribute)
|
30
30
|
thread_safe { attributes[attribute.name] = attribute }
|
31
31
|
end
|
32
32
|
alias_method :<<, :add_attribute
|
33
33
|
|
34
|
-
# @param attribute_set [SmartCore::
|
34
|
+
# @param attribute_set [SmartCore::Initializer::AttributeSet]
|
35
35
|
# @return [void]
|
36
36
|
#
|
37
37
|
# @api private
|
38
|
-
# @sinec 0.
|
38
|
+
# @sinec 0.5.0
|
39
39
|
def concat(attribute_set)
|
40
40
|
thread_safe { attributes.merge!(attribute_set.dup.attributes) }
|
41
41
|
end
|
42
42
|
|
43
|
-
# @param attribute [SmartCore::
|
43
|
+
# @param attribute [SmartCore::Initializer::Attribute]
|
44
44
|
# @return [Boolean]
|
45
45
|
#
|
46
46
|
# @api private
|
47
|
-
# @since 0.
|
47
|
+
# @since 0.5.0
|
48
48
|
def conflicts_with?(attribute)
|
49
49
|
thread_safe { attributes.key?(attribute.name) }
|
50
50
|
end
|
51
51
|
|
52
|
-
# @return [SmartCore::
|
52
|
+
# @return [SmartCore::Initializer::AttributeSet]
|
53
53
|
#
|
54
54
|
# @api private
|
55
|
-
# @since 0.
|
55
|
+
# @since 0.5.0
|
56
56
|
def dup
|
57
57
|
thread_safe do
|
58
58
|
self.class.new.tap do |duplicate|
|
@@ -66,7 +66,7 @@ class SmartCore::Operation::AttributeSet
|
|
66
66
|
# @return [Integer]
|
67
67
|
#
|
68
68
|
# @api private
|
69
|
-
# @since 0.
|
69
|
+
# @since 0.5.0
|
70
70
|
def size
|
71
71
|
thread_safe { attributes.size }
|
72
72
|
end
|
@@ -74,7 +74,7 @@ class SmartCore::Operation::AttributeSet
|
|
74
74
|
# @return [Enumerable]
|
75
75
|
#
|
76
76
|
# @api private
|
77
|
-
# @since 0.
|
77
|
+
# @since 0.5.0
|
78
78
|
def each(&block)
|
79
79
|
thread_safe { block_given? ? attributes.each_value(&block) : attributes.each_value }
|
80
80
|
end
|
@@ -85,7 +85,7 @@ class SmartCore::Operation::AttributeSet
|
|
85
85
|
# @return [Any]
|
86
86
|
#
|
87
87
|
# @api private
|
88
|
-
# @since 0.
|
88
|
+
# @since 0.5.0
|
89
89
|
def thread_safe(&block)
|
90
90
|
@access_lock.synchronize(&block)
|
91
91
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SmartCore::Initializer
|
4
|
+
# @api public
|
5
|
+
# @since 0.5.0
|
6
|
+
Error = Class.new(SmartCore::Error)
|
7
|
+
|
8
|
+
# @api public
|
9
|
+
# @since 0.5.0
|
10
|
+
ArgumentError = Class.new(SmartCore::ArgumentError)
|
11
|
+
|
12
|
+
# @api public
|
13
|
+
# @since 0.5.0
|
14
|
+
IncompatibleFinalizerTypeError = Class.new(ArgumentError)
|
15
|
+
|
16
|
+
# @api public
|
17
|
+
# @since 0.5.0
|
18
|
+
ParameterError = Class.new(ArgumentError)
|
19
|
+
|
20
|
+
# @api public
|
21
|
+
# @since 0.5.0
|
22
|
+
ParamOverlapError = Class.new(ParameterError)
|
23
|
+
|
24
|
+
# @api public
|
25
|
+
# @since 0.5.0
|
26
|
+
OptionError = Class.new(ArgumentError)
|
27
|
+
|
28
|
+
# @api public
|
29
|
+
# @since 0.5.0
|
30
|
+
OptionOverlapError = Class.new(OptionError)
|
31
|
+
|
32
|
+
# @api public
|
33
|
+
# @since 0.5.0
|
34
|
+
IncorrectAttributeNameError = Class.new(Error)
|
35
|
+
|
36
|
+
# @api public
|
37
|
+
# @since 0.5.0
|
38
|
+
UnregisteredTypeError = Class.new(Error)
|
39
|
+
|
40
|
+
# @api public
|
41
|
+
# @since 0.5.0
|
42
|
+
UnsupportedAttributePrivacyError = Class.new(Error)
|
43
|
+
|
44
|
+
# @api public
|
45
|
+
# @since 0.5.0
|
46
|
+
TypeError = Class.new(ArgumentError)
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.5.0
|
5
|
+
class SmartCore::Initializer::Extension
|
6
|
+
# @param additional_initialization_flow [Proc]
|
7
|
+
# @return [void]
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
# @since 0.5.0
|
11
|
+
def initialize(additional_initialization_flow)
|
12
|
+
@additional_initialization_flow = additional_initialization_flow
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param instance [Object]
|
16
|
+
# @return [void]
|
17
|
+
#
|
18
|
+
# @api private
|
19
|
+
# @since 0.5.0
|
20
|
+
def call(instance)
|
21
|
+
additional_initialization_flow.call(instance)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [void]
|
25
|
+
#
|
26
|
+
# @api private
|
27
|
+
# @since 0.5.0
|
28
|
+
def dup
|
29
|
+
self.class.new(additional_initialization_flow)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# @return [Proc]
|
35
|
+
#
|
36
|
+
# @api private
|
37
|
+
# @since 0.5.0
|
38
|
+
attr_reader :additional_initialization_flow
|
39
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.5.0
|
5
|
+
class SmartCore::Initializer::ExtensionDefiner
|
6
|
+
# @param processed_klass [Class]
|
7
|
+
# @return [void]
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
# @since 0.5.0
|
11
|
+
def initialize(processed_klass)
|
12
|
+
@processed_klass = processed_klass
|
13
|
+
@definition_lock = Mutex.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param raw_extension [Proc]
|
17
|
+
# @return [void]
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
# @since 0.5.0
|
21
|
+
def append_extension(raw_extension)
|
22
|
+
thread_safe do
|
23
|
+
extension = build_extension(raw_extension)
|
24
|
+
extend_initialization_flow(extension)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# @return [Class]
|
31
|
+
#
|
32
|
+
# @api private
|
33
|
+
# @since 0.5.0
|
34
|
+
attr_reader :processed_klass
|
35
|
+
|
36
|
+
# @param raw_extension [Proc]
|
37
|
+
# @return [SmartCore::Initializar::Extension]
|
38
|
+
#
|
39
|
+
# @api private
|
40
|
+
# @since 0.5.0
|
41
|
+
def build_extension(raw_extension)
|
42
|
+
SmartCore::Initializer::Extension.new(raw_extension)
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param extension [SmartCore::Initializer::Extension]
|
46
|
+
# @return [void]
|
47
|
+
#
|
48
|
+
# @api private
|
49
|
+
# @since 0.5.0
|
50
|
+
def extend_initialization_flow(extension)
|
51
|
+
processed_klass.__initialization_extensions__ << extension
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param block [Proc]
|
55
|
+
# @return [void]
|
56
|
+
#
|
57
|
+
# @api private
|
58
|
+
# @since 0.5.0
|
59
|
+
def thread_safe(&block)
|
60
|
+
@definition_lock.synchronize(&block)
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.5.0
|
5
|
+
class SmartCore::Initializer::ExtensionSet
|
6
|
+
# @since 0.5.0
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
# @return [Array<SmartCore::Initializer::InitializationExtension>]
|
10
|
+
#
|
11
|
+
# @api private
|
12
|
+
# @since 0.5.0
|
13
|
+
attr_reader :extensions
|
14
|
+
|
15
|
+
# @return [void]
|
16
|
+
#
|
17
|
+
# @api private
|
18
|
+
# @since 0.5.0
|
19
|
+
def initialize
|
20
|
+
@extensions = []
|
21
|
+
@access_lock = Mutex.new
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param extension [SmartCore::Initializer::InitializationExtension]
|
25
|
+
# @return [void]
|
26
|
+
#
|
27
|
+
# @api private
|
28
|
+
# @since 0.5.0
|
29
|
+
def add_extension(extension)
|
30
|
+
thread_safe { extensions << extension }
|
31
|
+
end
|
32
|
+
alias_method :<<, :add_extension
|
33
|
+
|
34
|
+
# @return [SmartCore::Initializer::ExtensionSet]
|
35
|
+
#
|
36
|
+
# @api private
|
37
|
+
# @since 0.5.0
|
38
|
+
def dup
|
39
|
+
thread_safe do
|
40
|
+
self.class.new.tap do |duplicate|
|
41
|
+
extensions.each do |extension|
|
42
|
+
duplicate.add_extension(extension.dup)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Enumerable]
|
49
|
+
#
|
50
|
+
# @api private
|
51
|
+
# @since 0.5.0
|
52
|
+
def each(&block)
|
53
|
+
thread_safe { block_given? ? extensions.each(&block) : extensions.each }
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param extension_set [SmartCore::Initializer::ExtensionSet]
|
57
|
+
# @return [void]
|
58
|
+
#
|
59
|
+
# @api private
|
60
|
+
# @since 0.5.0
|
61
|
+
def concat(extension_set)
|
62
|
+
thread_safe { extensions.concat(extension_set.dup.extensions) }
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# @param block [Proc]
|
68
|
+
# @return [Any]
|
69
|
+
#
|
70
|
+
# @api private
|
71
|
+
# @since 0.5.0
|
72
|
+
def thread_safe(&block)
|
73
|
+
@access_lock.synchronize(&block)
|
74
|
+
end
|
75
|
+
end
|
@@ -1,36 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
module SmartCore::Initializer
|
4
4
|
# @api private
|
5
|
-
# @since 0.
|
5
|
+
# @since 0.5.0
|
6
6
|
module InitializationDSL
|
7
7
|
class << self
|
8
8
|
# @param base_klass [Class]
|
9
9
|
# @return [void]
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
-
# @since 0.
|
12
|
+
# @since 0.5.0
|
13
13
|
def included(base_klass) # rubocop:disable Metrics/AbcSize
|
14
|
-
|
15
|
-
base_klass.
|
16
|
-
|
14
|
+
# rubocop:disable Metrics/LineLength
|
15
|
+
base_klass.instance_variable_set(:@__initialization_extension_definer__, ExtensionDefiner.new(base_klass))
|
16
|
+
base_klass.instance_variable_set(:@__initialization_extensions__, ExtensionSet.new)
|
17
17
|
base_klass.instance_variable_set(:@__attr_definer__, AttributeDefiner.new(base_klass))
|
18
18
|
base_klass.instance_variable_set(:@__params__, AttributeSet.new)
|
19
19
|
base_klass.instance_variable_set(:@__options__, AttributeSet.new)
|
20
|
+
# rubocop:enable Metrics/LineLength
|
21
|
+
|
22
|
+
base_klass.extend(ClassMethods)
|
23
|
+
base_klass.extend(DSLMethods)
|
24
|
+
base_klass.singleton_class.prepend(InitializationMethods)
|
20
25
|
|
21
26
|
base_klass.singleton_class.prepend(Module.new do
|
22
27
|
# @param child_klass [Class]
|
23
28
|
# @return [void]
|
24
29
|
#
|
25
30
|
# @api private
|
26
|
-
# @since 0.
|
27
|
-
def inherited(child_klass)
|
28
|
-
|
29
|
-
|
31
|
+
# @since 0.5.0
|
32
|
+
def inherited(child_klass) # rubocop:disable Metrics/AbcSize
|
33
|
+
# rubocop:disable Metrics/LineLength
|
34
|
+
child_klass.instance_variable_set(:@__initialization_extension_definer__, ExtensionDefiner.new(child_klass))
|
35
|
+
child_klass.instance_variable_set(:@__initialization_extensions__, ExtensionSet.new)
|
30
36
|
child_klass.instance_variable_set(:@__attr_definer__, AttributeDefiner.new(child_klass))
|
31
37
|
child_klass.instance_variable_set(:@__params__, AttributeSet.new)
|
32
38
|
child_klass.instance_variable_set(:@__options__, AttributeSet.new)
|
39
|
+
# rubocop:enable Metrics/LineLength
|
40
|
+
|
41
|
+
child_klass.singleton_class.prepend(InitializationMethods)
|
33
42
|
|
43
|
+
child_klass.__initialization_extensions__.concat(__initialization_extensions__)
|
34
44
|
child_klass.__params__.concat(__params__)
|
35
45
|
child_klass.__options__.concat(__options__)
|
36
46
|
|
@@ -41,14 +51,14 @@ class SmartCore::Operation
|
|
41
51
|
end
|
42
52
|
|
43
53
|
# @api private
|
44
|
-
# @since 0.
|
54
|
+
# @since 0.5.0
|
45
55
|
module InitializationMethods
|
46
56
|
# @param parameters [Any]
|
47
57
|
# @param options [Hash<Symbol,Any>]
|
48
58
|
# @return [Any]
|
49
59
|
#
|
50
60
|
# @api public
|
51
|
-
# @since 0.
|
61
|
+
# @since 0.5.0
|
52
62
|
def new(*parameters, **options)
|
53
63
|
allocate.tap do |object|
|
54
64
|
InstanceBuilder.call(object, self, parameters, options)
|
@@ -57,22 +67,67 @@ class SmartCore::Operation
|
|
57
67
|
end
|
58
68
|
|
59
69
|
# @api private
|
60
|
-
# @since 0.
|
70
|
+
# @since 0.5.0
|
71
|
+
module ClassMethods
|
72
|
+
# @return [SmartCore::Initializer::AttributeSet]
|
73
|
+
#
|
74
|
+
# @api private
|
75
|
+
# @since 0.5.0
|
76
|
+
def __params__
|
77
|
+
@__params__
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [SmartCore::Initializer::AttributeSet]
|
81
|
+
#
|
82
|
+
# @api private
|
83
|
+
# @since 0.5.0
|
84
|
+
def __options__
|
85
|
+
@__options__
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [SmartCore::Initializer::AttributeDefiner]
|
89
|
+
#
|
90
|
+
# @api private
|
91
|
+
# @since 0.5.0
|
92
|
+
def __attr_definer__
|
93
|
+
@__attr_definer__
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [SmartCore::Initializer::ExtensionSet]
|
97
|
+
#
|
98
|
+
# @api private
|
99
|
+
# @since 0.5.0
|
100
|
+
def __initialization_extensions__
|
101
|
+
@__initialization_extensions__
|
102
|
+
end
|
103
|
+
|
104
|
+
# @return [SmartCore::Initializer::ExtensionDefiner]
|
105
|
+
#
|
106
|
+
# @api private
|
107
|
+
# @since 0.5.0
|
108
|
+
def __initialization_extension_definer__
|
109
|
+
@__initialization_extension_definer__
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# @api private
|
114
|
+
# @since 0.5.0
|
61
115
|
module DSLMethods
|
62
116
|
# @param param_name [String, Symbol]
|
117
|
+
# @param options [Hash<Symbol,Any>]
|
63
118
|
# @return [void]
|
64
119
|
#
|
65
120
|
# @api public
|
66
|
-
# @since 0.
|
67
|
-
def param(param_name)
|
68
|
-
__attr_definer__.define_param(param_name)
|
121
|
+
# @since 0.5.0
|
122
|
+
def param(param_name, type = :__any__, **options)
|
123
|
+
__attr_definer__.define_param(param_name, type, **options)
|
69
124
|
end
|
70
125
|
|
71
126
|
# @param param_names [Array<String, Symbol>]
|
72
127
|
# @return [void]
|
73
128
|
#
|
74
129
|
# @api public
|
75
|
-
# @since 0.
|
130
|
+
# @since 0.5.0
|
76
131
|
def params(*param_names)
|
77
132
|
__attr_definer__.define_params(*param_names)
|
78
133
|
end
|
@@ -82,42 +137,27 @@ class SmartCore::Operation
|
|
82
137
|
# @return [void]
|
83
138
|
#
|
84
139
|
# @api public
|
85
|
-
# @since 0.
|
86
|
-
def option(option_name, **options)
|
87
|
-
__attr_definer__.define_option(option_name, **options)
|
140
|
+
# @since 0.5.0
|
141
|
+
def option(option_name, type = :__any__, **options)
|
142
|
+
__attr_definer__.define_option(option_name, type, **options)
|
88
143
|
end
|
89
144
|
|
90
145
|
# @param option_names [Array<String, Symbol>]
|
91
146
|
# @return [void]
|
92
147
|
#
|
93
148
|
# @api public
|
94
|
-
# @since 0.
|
149
|
+
# @since 0.5.0
|
95
150
|
def options(*option_names)
|
96
151
|
__attr_definer__.define_options(*option_names)
|
97
152
|
end
|
98
153
|
|
99
|
-
# @
|
100
|
-
#
|
101
|
-
# @api private
|
102
|
-
# @since 0.2.0
|
103
|
-
def __params__
|
104
|
-
@__params__
|
105
|
-
end
|
106
|
-
|
107
|
-
# @return [SmartCore::Operation::AttributeSet]
|
108
|
-
#
|
109
|
-
# @api private
|
110
|
-
# @since 0.2.0
|
111
|
-
def __options__
|
112
|
-
@__options__
|
113
|
-
end
|
114
|
-
|
115
|
-
# @return [SmartCore::Operation::AttributeDefiner]
|
154
|
+
# @param block [Proc]
|
155
|
+
# @return [void]
|
116
156
|
#
|
117
|
-
# @api
|
118
|
-
# @since 0.
|
119
|
-
def
|
120
|
-
|
157
|
+
# @api public
|
158
|
+
# @since 0.5.0
|
159
|
+
def extend_initialization_flow(&block)
|
160
|
+
__initialization_extension_definer__.append_extension(block)
|
121
161
|
end
|
122
162
|
end
|
123
163
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.5.0
|
5
|
+
module SmartCore::Initializer::InstanceAttributeAccessing
|
6
|
+
# @return [Hash<Symbol,Any>]
|
7
|
+
#
|
8
|
+
# @api public
|
9
|
+
# @since 0.5.0
|
10
|
+
def params
|
11
|
+
__collect_params__
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Hash<Symbol,Any>]
|
15
|
+
#
|
16
|
+
# @api public
|
17
|
+
# @since 0.5.0
|
18
|
+
def options
|
19
|
+
__collect_options__
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Hash<Symbol,Any>]
|
23
|
+
#
|
24
|
+
# @api public
|
25
|
+
# @since 0.5.0
|
26
|
+
def attributes
|
27
|
+
__collect_params__.merge(__collect_options__)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Hash<Symbol,Any>]
|
31
|
+
#
|
32
|
+
# @api private
|
33
|
+
# @since 0.5.0
|
34
|
+
def __collect_params__
|
35
|
+
self.class.__params__.each_with_object({}) do |param, memo|
|
36
|
+
memo[param.name] = instance_variable_get("@#{param.name}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Hash<Symbol,Any>]
|
41
|
+
#
|
42
|
+
# @api private
|
43
|
+
# @since 0.5.0
|
44
|
+
def __collect_options__
|
45
|
+
self.class.__options__.each_with_object({}) do |option, memo|
|
46
|
+
memo[option.name] = instance_variable_get("@#{option.name}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|