smart_initializer 0.5.0 → 0.9.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 +1 -1
- data/CHANGELOG.md +46 -1
- data/Gemfile.lock +45 -44
- data/LICENSE.txt +1 -1
- data/README.md +283 -40
- data/bin/console +2 -2
- data/gemfiles/with_external_deps.gemfile.lock +38 -38
- data/gemfiles/without_external_deps.gemfile.lock +50 -45
- data/lib/smart_core/initializer/attribute/factory/base.rb +145 -0
- data/lib/smart_core/initializer/attribute/factory/option.rb +107 -0
- data/lib/smart_core/initializer/attribute/factory/param.rb +63 -0
- data/lib/smart_core/initializer/attribute/factory.rb +5 -199
- data/lib/smart_core/initializer/attribute/finalizer/abstract.rb +2 -0
- data/lib/smart_core/initializer/attribute/finalizer/instance_method.rb +1 -1
- data/lib/smart_core/initializer/attribute/finalizer.rb +5 -5
- data/lib/smart_core/initializer/attribute/list.rb +20 -0
- data/lib/smart_core/initializer/attribute/{parameters.rb → value/base.rb} +35 -65
- data/lib/smart_core/initializer/attribute/value/option.rb +101 -0
- data/lib/smart_core/initializer/attribute/value/param.rb +24 -0
- data/lib/smart_core/initializer/attribute/value.rb +9 -0
- data/lib/smart_core/initializer/attribute.rb +3 -112
- data/lib/smart_core/initializer/configuration.rb +9 -0
- data/lib/smart_core/initializer/constructor/definer.rb +135 -46
- data/lib/smart_core/initializer/constructor.rb +29 -14
- data/lib/smart_core/initializer/dsl.rb +38 -24
- data/lib/smart_core/initializer/errors.rb +20 -0
- data/lib/smart_core/initializer/functionality.rb +7 -8
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb +13 -2
- data/lib/smart_core/initializer/settings/auto_cast.rb +40 -0
- data/lib/smart_core/initializer/settings/base.rb +49 -0
- data/lib/smart_core/initializer/settings/duplicator.rb +5 -0
- data/lib/smart_core/initializer/settings/strict_options.rb +40 -0
- data/lib/smart_core/initializer/settings/type_system.rb +10 -28
- data/lib/smart_core/initializer/settings.rb +40 -0
- data/lib/smart_core/initializer/type_system/interop/abstract_factory.rb +12 -2
- data/lib/smart_core/initializer/type_system/interop.rb +10 -1
- data/lib/smart_core/initializer/type_system/registry.rb +2 -1
- data/lib/smart_core/initializer/type_system/smart_types/abstract_factory.rb +13 -2
- data/lib/smart_core/initializer/type_system/smart_types.rb +2 -2
- data/lib/smart_core/initializer/version.rb +2 -2
- data/lib/smart_core/initializer.rb +14 -4
- data/smart_initializer.gemspec +3 -3
- metadata +18 -9
@@ -9,6 +9,14 @@ module SmartCore::Initializer
|
|
9
9
|
# @since 0.1.0
|
10
10
|
ArgumentError = Class.new(SmartCore::ArgumentError)
|
11
11
|
|
12
|
+
# @api public
|
13
|
+
# @since 0.8.0
|
14
|
+
AttributeError = Class.new(Error)
|
15
|
+
|
16
|
+
# @api public
|
17
|
+
# @since 0.8.0
|
18
|
+
UndefinedAttributeError = Class.new(AttributeError)
|
19
|
+
|
12
20
|
# @api public
|
13
21
|
# @since 0.1.0
|
14
22
|
ParameterArgumentError = Class.new(ArgumentError)
|
@@ -17,6 +25,14 @@ module SmartCore::Initializer
|
|
17
25
|
# @since 0.1.0
|
18
26
|
OptionArgumentError = Class.new(ArgumentError)
|
19
27
|
|
28
|
+
# @api public
|
29
|
+
# @since 0.8.0
|
30
|
+
AliasArgumentError = Class.new(ArgumentError)
|
31
|
+
|
32
|
+
# @api public
|
33
|
+
# @since 0.8.0
|
34
|
+
SettingArgumentError = Class.new(ArgumentError)
|
35
|
+
|
20
36
|
# @api public
|
21
37
|
# @since 0.1.0
|
22
38
|
NoDefaultValueError = Class.new(Error)
|
@@ -53,6 +69,10 @@ module SmartCore::Initializer
|
|
53
69
|
# @since 0.1.0
|
54
70
|
TypeSystemError = Class.new(Error)
|
55
71
|
|
72
|
+
# @api public
|
73
|
+
# @since 0.5.1
|
74
|
+
IncorrectTypeError = Class.new(TypeSystemError)
|
75
|
+
|
56
76
|
# @api public
|
57
77
|
# @since 0.1.0
|
58
78
|
TypeAliasNotFoundError = Class.new(TypeSystemError)
|
@@ -3,23 +3,22 @@
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.3.0
|
5
5
|
module SmartCore::Initializer::Functionality
|
6
|
-
# @return [NilClass]
|
7
|
-
#
|
8
|
-
# @api private
|
9
|
-
# @since 0.3.0
|
10
|
-
INITIAL_TYPE_SYSTEM = nil
|
11
|
-
|
12
6
|
class << self
|
13
|
-
# @option type_system [String, Symbol
|
7
|
+
# @option type_system [String, Symbol]
|
8
|
+
# @option strict_option [Boolean]
|
9
|
+
# @option auto_cast [Boolean]
|
14
10
|
# @return [Module]
|
15
11
|
#
|
16
12
|
# @api private
|
17
13
|
# @since 0.3.0
|
18
|
-
|
14
|
+
# @version 0.8.0
|
15
|
+
def includable_module(type_system:, strict_options:, auto_cast:)
|
19
16
|
Module.new.tap do |extension|
|
20
17
|
extension.singleton_class.define_method(:included) do |base_klass|
|
21
18
|
base_klass.include(::SmartCore::Initializer)
|
22
19
|
base_klass.__initializer_settings__.type_system = type_system
|
20
|
+
base_klass.__initializer_settings__.strict_options = strict_options
|
21
|
+
base_klass.__initializer_settings__.auto_cast = auto_cast
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
@@ -28,6 +28,15 @@ module SmartCore::Initializer::TypeSystem
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
# @param type [Any]
|
32
|
+
# @return [String]
|
33
|
+
#
|
34
|
+
# @api private
|
35
|
+
# @since 0.5.1
|
36
|
+
def build_identifier(type)
|
37
|
+
type.name
|
38
|
+
end
|
39
|
+
|
31
40
|
# @param type [Thy::Type, #check]
|
32
41
|
# @return [SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Valid]
|
33
42
|
#
|
@@ -63,6 +72,7 @@ module SmartCore::Initializer::TypeSystem
|
|
63
72
|
ThyTypes::Operation::Cast.new(type)
|
64
73
|
end
|
65
74
|
|
75
|
+
# @param identifier [String]
|
66
76
|
# @param valid_op [SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Valid]
|
67
77
|
# @param valid_op [SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Validate]
|
68
78
|
# @param valid_op [SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Cast]
|
@@ -70,8 +80,9 @@ module SmartCore::Initializer::TypeSystem
|
|
70
80
|
#
|
71
81
|
# @api private
|
72
82
|
# @since 0.1.0
|
73
|
-
|
74
|
-
|
83
|
+
# @version 0.5.1
|
84
|
+
def build_interop(identifier, valid_op, validate_op, cast_op)
|
85
|
+
ThyTypes.new(identifier, valid_op, validate_op, cast_op)
|
75
86
|
end
|
76
87
|
end
|
77
88
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.8.0
|
5
|
+
class SmartCore::Initializer::Settings::AutoCast < SmartCore::Initializer::Settings::Base
|
6
|
+
# @return [void]
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
# @since 0.8.0
|
10
|
+
def initialize
|
11
|
+
@value = nil
|
12
|
+
@lock = SmartCore::Engine::Lock.new
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Boolean]
|
16
|
+
#
|
17
|
+
# @api private
|
18
|
+
# @since 0.8.0
|
19
|
+
def resolve
|
20
|
+
thread_safe do
|
21
|
+
@value == nil ? SmartCore::Initializer::Configuration[:auto_cast] : @value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param value [Boolean]
|
26
|
+
# @return [void]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
# @since 0.8.0
|
30
|
+
def assign(value)
|
31
|
+
thread_safe do
|
32
|
+
raise(
|
33
|
+
SmartCore::Initializer::SettingArgumentError,
|
34
|
+
":auto_cast setting should be a type of boolean (got: `#{value.class}`)"
|
35
|
+
) unless value.is_a?(::TrueClass) || value.is_a?(::FalseClass)
|
36
|
+
|
37
|
+
@value = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.8.0
|
5
|
+
class SmartCore::Initializer::Settings::Base
|
6
|
+
# @return [void]
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
# @since 0.8.0
|
10
|
+
def initialize
|
11
|
+
@value = nil
|
12
|
+
@lock = SmartCore::Engine::Lock.new
|
13
|
+
end
|
14
|
+
|
15
|
+
# @!method resolve
|
16
|
+
# @return [Any]
|
17
|
+
# @api private
|
18
|
+
# @since 0.8.0
|
19
|
+
|
20
|
+
# @!method assign(value)
|
21
|
+
# @param value [Any]
|
22
|
+
# @return [void]
|
23
|
+
# @raise [SmartCore::Initializer::SettingArgumentError]
|
24
|
+
# @api private
|
25
|
+
# @since 0.8.0
|
26
|
+
|
27
|
+
# @return [SmartCore::Initializer::Settings::Base]
|
28
|
+
#
|
29
|
+
# @api private
|
30
|
+
# @since 0.8.0
|
31
|
+
def dup
|
32
|
+
thread_safe do
|
33
|
+
self.class.new.tap do |duplicate|
|
34
|
+
duplicate.instance_variable_set(:@value, @value)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
# @param block [Block]
|
42
|
+
# @return [Any]
|
43
|
+
#
|
44
|
+
# @api private
|
45
|
+
# @since 0.8.0
|
46
|
+
def thread_safe(&block)
|
47
|
+
@lock.synchronize(&block)
|
48
|
+
end
|
49
|
+
end
|
@@ -9,11 +9,16 @@ module SmartCore::Initializer::Settings::Duplicator
|
|
9
9
|
#
|
10
10
|
# @api private
|
11
11
|
# @since 0.1.0
|
12
|
+
# @version 0.8.0
|
12
13
|
def duplicate(settings)
|
13
14
|
SmartCore::Initializer::Settings.new.tap do |new_instance|
|
14
15
|
type_system = settings.instance_variable_get(:@type_system).dup
|
16
|
+
strict_options = settings.instance_variable_get(:@strict_options).dup
|
17
|
+
auto_cast = settings.instance_variable_get(:@auto_cast).dup
|
15
18
|
|
16
19
|
new_instance.instance_variable_set(:@type_system, type_system)
|
20
|
+
new_instance.instance_variable_set(:@strict_options, strict_options)
|
21
|
+
new_instance.instance_variable_set(:@auto_cast, auto_cast)
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.8.0
|
5
|
+
class SmartCore::Initializer::Settings::StrictOptions < SmartCore::Initializer::Settings::Base
|
6
|
+
# @return [void]
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
# @since 0.8.0
|
10
|
+
def initialize
|
11
|
+
@value = nil
|
12
|
+
@lock = SmartCore::Engine::Lock.new
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Boolean]
|
16
|
+
#
|
17
|
+
# @api private
|
18
|
+
# @since 0.8.0
|
19
|
+
def resolve
|
20
|
+
thread_safe do
|
21
|
+
@value == nil ? SmartCore::Initializer::Configuration[:strict_options] : @value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param value [Boolean]
|
26
|
+
# @return [void]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
# @since 0.8.0
|
30
|
+
def assign(value)
|
31
|
+
thread_safe do
|
32
|
+
raise(
|
33
|
+
SmartCore::Initializer::SettingArgumentError,
|
34
|
+
":strict_options setting should be a type of boolean (got: `#{value.class}`)"
|
35
|
+
) unless value.is_a?(::TrueClass) || value.is_a?(::FalseClass)
|
36
|
+
|
37
|
+
@value = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.1.0
|
5
|
-
|
5
|
+
# @version 0.8.0
|
6
|
+
class SmartCore::Initializer::Settings::TypeSystem < SmartCore::Initializer::Settings::Base
|
6
7
|
# @return [void]
|
7
8
|
#
|
8
9
|
# @api private
|
9
10
|
# @since 0.1.0
|
11
|
+
# @version 0.8.0
|
10
12
|
def initialize
|
11
|
-
@
|
13
|
+
@value = nil
|
12
14
|
@lock = SmartCore::Engine::Lock.new
|
13
15
|
end
|
14
16
|
|
@@ -26,9 +28,10 @@ class SmartCore::Initializer::Settings::TypeSystem
|
|
26
28
|
#
|
27
29
|
# @api private
|
28
30
|
# @since 0.1.0
|
31
|
+
# @version 0.8.0
|
29
32
|
def resolve
|
30
33
|
thread_safe do
|
31
|
-
@
|
34
|
+
@value == nil ? SmartCore::Initializer::Configuration[:default_type_system] : @value
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -37,33 +40,12 @@ class SmartCore::Initializer::Settings::TypeSystem
|
|
37
40
|
#
|
38
41
|
# @api private
|
39
42
|
# @since 0.1.0
|
43
|
+
# @version 0.8.0
|
40
44
|
def assign(value)
|
41
45
|
thread_safe do
|
42
|
-
|
43
|
-
|
46
|
+
# NOTE: type system existence validation
|
47
|
+
SmartCore::Initializer::TypeSystem.resolve(value)
|
48
|
+
@value = value
|
44
49
|
end
|
45
50
|
end
|
46
|
-
|
47
|
-
# @return [SmartCore::Initializer::Settings::TypeSystem]
|
48
|
-
#
|
49
|
-
# @api private
|
50
|
-
# @since 0.1.0
|
51
|
-
def dup
|
52
|
-
thread_safe do
|
53
|
-
self.class.new.tap do |duplicate|
|
54
|
-
duplicate.instance_variable_set(:@type_system, @type_system)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
# @param block [Block]
|
62
|
-
# @return [Any]
|
63
|
-
#
|
64
|
-
# @api private
|
65
|
-
# @since 0.1.0
|
66
|
-
def thread_safe(&block)
|
67
|
-
@lock.synchronize(&block)
|
68
|
-
end
|
69
51
|
end
|
@@ -3,15 +3,21 @@
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.1.0
|
5
5
|
class SmartCore::Initializer::Settings
|
6
|
+
require_relative 'settings/base'
|
6
7
|
require_relative 'settings/type_system'
|
8
|
+
require_relative 'settings/strict_options'
|
9
|
+
require_relative 'settings/auto_cast'
|
7
10
|
require_relative 'settings/duplicator'
|
8
11
|
|
9
12
|
# @return [void]
|
10
13
|
#
|
11
14
|
# @api private
|
12
15
|
# @since 0.1.0
|
16
|
+
# @version 0.8.0
|
13
17
|
def initialize
|
14
18
|
@type_system = TypeSystem.new
|
19
|
+
@strict_options = StrictOptions.new
|
20
|
+
@auto_cast = AutoCast.new
|
15
21
|
end
|
16
22
|
|
17
23
|
# @return [Any]
|
@@ -30,6 +36,22 @@ class SmartCore::Initializer::Settings
|
|
30
36
|
@type_system.resolve
|
31
37
|
end
|
32
38
|
|
39
|
+
# @return [Boolean]
|
40
|
+
#
|
41
|
+
# @api private
|
42
|
+
# @since 0.8.0
|
43
|
+
def strict_options
|
44
|
+
@strict_options.resolve
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Boolean]
|
48
|
+
#
|
49
|
+
# @api private
|
50
|
+
# @since 0.8.0
|
51
|
+
def auto_cast
|
52
|
+
@auto_cast.resolve
|
53
|
+
end
|
54
|
+
|
33
55
|
# @param value [String, System]
|
34
56
|
# @return [void]
|
35
57
|
#
|
@@ -39,6 +61,24 @@ class SmartCore::Initializer::Settings
|
|
39
61
|
@type_system.assign(value)
|
40
62
|
end
|
41
63
|
|
64
|
+
# @param value [Boolean]
|
65
|
+
# @return [void]
|
66
|
+
#
|
67
|
+
# @api private
|
68
|
+
# @since 0.8.0
|
69
|
+
def strict_options=(value)
|
70
|
+
@strict_options.assign(value)
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param value [Boolean]
|
74
|
+
# @return [void]
|
75
|
+
#
|
76
|
+
# @api private
|
77
|
+
# @since 0.8.0
|
78
|
+
def auto_cast=(value)
|
79
|
+
@auto_cast.assign(value)
|
80
|
+
end
|
81
|
+
|
42
82
|
# @return [SmartCore::Initializer::Settings]
|
43
83
|
#
|
44
84
|
# @api private
|
@@ -13,11 +13,12 @@ class SmartCore::Initializer::TypeSystem::Interop::AbstractFactory
|
|
13
13
|
def create(type)
|
14
14
|
prevent_incompatible_type!(type)
|
15
15
|
|
16
|
+
identifier = build_identifier(type)
|
16
17
|
valid_op = build_valid_operation(type)
|
17
18
|
validate_op = build_validate_operation(type)
|
18
19
|
cast_op = build_cast_operation(type)
|
19
20
|
|
20
|
-
build_interop(valid_op, validate_op, cast_op)
|
21
|
+
build_interop(identifier, valid_op, validate_op, cast_op)
|
21
22
|
end
|
22
23
|
|
23
24
|
# @return [Any]
|
@@ -26,6 +27,13 @@ class SmartCore::Initializer::TypeSystem::Interop::AbstractFactory
|
|
26
27
|
# @since 0.1.0
|
27
28
|
def generic_type_object; end
|
28
29
|
|
30
|
+
# @param type [Any]
|
31
|
+
# @return [String]
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
# @since 0.5.1
|
35
|
+
def build_identifier(type); end
|
36
|
+
|
29
37
|
# @param type [Any]
|
30
38
|
# @return [void]
|
31
39
|
#
|
@@ -58,6 +66,7 @@ class SmartCore::Initializer::TypeSystem::Interop::AbstractFactory
|
|
58
66
|
# @since 0.1.0
|
59
67
|
def build_cast_operation(type); end
|
60
68
|
|
69
|
+
# @param identifier [String]
|
61
70
|
# @param valid_op [SmartCore::Initializer::TypeSystem::Interop::Operation]
|
62
71
|
# @param validate_op [SmartCore::Initializer::TypeSystem::Interop::Operation]
|
63
72
|
# @param cast_op [SmartCore::Initializer::TypeSystem::Interop::Operation]
|
@@ -65,6 +74,7 @@ class SmartCore::Initializer::TypeSystem::Interop::AbstractFactory
|
|
65
74
|
#
|
66
75
|
# @api private
|
67
76
|
# @since 0.1.0
|
68
|
-
|
77
|
+
# @version 0.5.1
|
78
|
+
def build_interop(identifier, valid_op, validate_op, cast_op); end
|
69
79
|
end
|
70
80
|
end
|
@@ -41,6 +41,13 @@ class SmartCore::Initializer::TypeSystem::Interop
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
# @return [String]
|
45
|
+
#
|
46
|
+
# @api private
|
47
|
+
# @since 0.5.1
|
48
|
+
attr_reader :identifier
|
49
|
+
|
50
|
+
# @param identifier [String]
|
44
51
|
# @param valid_op [SmartCore::Initializer::TypeSystem::Interop::Operation]
|
45
52
|
# @param validate_op [SmartCore::Initializer::TypeSystem::Interop::Operation]
|
46
53
|
# @param cast_op [SmartCore::Initializer::TypeSystem::Interop::Operation]
|
@@ -48,7 +55,9 @@ class SmartCore::Initializer::TypeSystem::Interop
|
|
48
55
|
#
|
49
56
|
# @api private
|
50
57
|
# @since 0.1.0
|
51
|
-
|
58
|
+
# @version 0.5.1
|
59
|
+
def initialize(identifier, valid_op, validate_op, cast_op)
|
60
|
+
@identifier = identifier
|
52
61
|
@valid_op = valid_op
|
53
62
|
@validate_op = validate_op
|
54
63
|
@cast_op = cast_op
|
@@ -126,6 +126,7 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
126
126
|
#
|
127
127
|
# @api private
|
128
128
|
# @since 0.1.0
|
129
|
+
# @version 0.8.0
|
129
130
|
def fetch(system_identifier)
|
130
131
|
identifier = indifferently_accessible_identifier(system_identifier)
|
131
132
|
|
@@ -133,7 +134,7 @@ class SmartCore::Initializer::TypeSystem::Registry
|
|
133
134
|
systems.fetch(identifier)
|
134
135
|
rescue ::KeyError
|
135
136
|
raise(SmartCore::Initializer::UnsupportedTypeSystemError, <<~ERROR_MESSAGE)
|
136
|
-
|
137
|
+
`#{identifier}` type system is not supported.
|
137
138
|
ERROR_MESSAGE
|
138
139
|
end
|
139
140
|
end
|
@@ -22,6 +22,15 @@ module SmartCore::Initializer::TypeSystem
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
# @param type [Any]
|
26
|
+
# @return [String]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
# @since 0.5.1
|
30
|
+
def build_identifier(type)
|
31
|
+
type.name
|
32
|
+
end
|
33
|
+
|
25
34
|
# @param type [SmartCore::Types::Primitive]
|
26
35
|
# @return [SmartCore::Initializer::TypeSystem::SmartTypes::Operation::Valid]
|
27
36
|
#
|
@@ -57,6 +66,7 @@ module SmartCore::Initializer::TypeSystem
|
|
57
66
|
SmartTypes::Operation::Cast.new(type)
|
58
67
|
end
|
59
68
|
|
69
|
+
# @param identifier [String]
|
60
70
|
# @param valid_op [SmartCore::Initializer::TypeSystem::SmartTypes::Operation::Valid]
|
61
71
|
# @param valid_op [SmartCore::Initializer::TypeSystem::SmartTypes::Operation::Validate]
|
62
72
|
# @param valid_op [SmartCore::Initializer::TypeSystem::SmartTypes::Operation::Cast]
|
@@ -64,8 +74,9 @@ module SmartCore::Initializer::TypeSystem
|
|
64
74
|
#
|
65
75
|
# @api private
|
66
76
|
# @since 0.1.0
|
67
|
-
|
68
|
-
|
77
|
+
# @version 0.5.1
|
78
|
+
def build_interop(identifier, valid_op, validate_op, cast_op)
|
79
|
+
SmartTypes.new(identifier, valid_op, validate_op, cast_op)
|
69
80
|
end
|
70
81
|
end
|
71
82
|
end
|
@@ -21,7 +21,7 @@ class SmartCore::Initializer::TypeSystem::SmartTypes < SmartCore::Initializer::T
|
|
21
21
|
type_alias('value.proc', SmartCore::Types::Value::Proc)
|
22
22
|
type_alias('value.class', SmartCore::Types::Value::Class)
|
23
23
|
type_alias('value.module', SmartCore::Types::Value::Module)
|
24
|
-
type_alias('value.
|
24
|
+
type_alias('value.time', SmartCore::Types::Value::Time)
|
25
25
|
type_alias('value.date_time', SmartCore::Types::Value::DateTime)
|
26
26
|
type_alias('value.date', SmartCore::Types::Value::Date)
|
27
27
|
type_alias('value.time_based', SmartCore::Types::Value::TimeBased)
|
@@ -41,7 +41,7 @@ class SmartCore::Initializer::TypeSystem::SmartTypes < SmartCore::Initializer::T
|
|
41
41
|
type_alias(:proc, SmartCore::Types::Value::Proc)
|
42
42
|
type_alias(:class, SmartCore::Types::Value::Class)
|
43
43
|
type_alias(:module, SmartCore::Types::Value::Module)
|
44
|
-
type_alias(:
|
44
|
+
type_alias(:time, SmartCore::Types::Value::Time)
|
45
45
|
type_alias(:date_time, SmartCore::Types::Value::DateTime)
|
46
46
|
type_alias(:date, SmartCore::Types::Value::Date)
|
47
47
|
type_alias(:time_based, SmartCore::Types::Value::TimeBased)
|
@@ -43,15 +43,25 @@ module SmartCore
|
|
43
43
|
end
|
44
44
|
|
45
45
|
class << self
|
46
|
-
# @option type_system [String, Symbol
|
46
|
+
# @option type_system [String, Symbol]
|
47
|
+
# @option strict_options [Boolean]
|
48
|
+
# @option auto_cast [Boolean]
|
47
49
|
# @return [Module]
|
48
50
|
#
|
49
51
|
# @api public
|
50
52
|
# @since 0.1.0
|
51
|
-
# @version 0.
|
53
|
+
# @version 0.8.0
|
52
54
|
# rubocop:disable Naming/MethodName
|
53
|
-
def Initializer(
|
54
|
-
SmartCore::Initializer::
|
55
|
+
def Initializer(
|
56
|
+
type_system: SmartCore::Initializer::Configuration[:default_type_system],
|
57
|
+
strict_options: SmartCore::Initializer::Configuration[:strict_options],
|
58
|
+
auto_cast: SmartCore::Initializer::Configuration[:auto_cast]
|
59
|
+
)
|
60
|
+
SmartCore::Initializer::Functionality.includable_module(
|
61
|
+
type_system: type_system,
|
62
|
+
strict_options: strict_options,
|
63
|
+
auto_cast: auto_cast
|
64
|
+
)
|
55
65
|
end
|
56
66
|
# rubocop:enable Naming/MethodName
|
57
67
|
end
|
data/smart_initializer.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative 'lib/smart_core/initializer/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
6
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
|
7
7
|
|
8
8
|
spec.name = 'smart_initializer'
|
9
9
|
spec.version = SmartCore::Initializer::VERSION
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency 'bundler', '~> 2.2'
|
38
38
|
spec.add_development_dependency 'rake', '~> 13.0'
|
39
39
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
40
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 1.
|
40
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 1.23'
|
41
41
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
42
|
-
spec.add_development_dependency 'pry', '~> 0.
|
42
|
+
spec.add_development_dependency 'pry', '~> 0.14'
|
43
43
|
end
|