smart_initializer 0.1.0.alpha3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +36 -5
  4. data/CHANGELOG.md +19 -0
  5. data/Gemfile.lock +63 -43
  6. data/README.md +227 -11
  7. data/Rakefile +1 -1
  8. data/bin/rspec +54 -0
  9. data/gemfiles/with_external_deps.gemfile +7 -0
  10. data/gemfiles/with_external_deps.gemfile.lock +102 -0
  11. data/gemfiles/without_external_deps.gemfile +5 -0
  12. data/gemfiles/without_external_deps.gemfile.lock +100 -0
  13. data/lib/smart_core/initializer.rb +44 -34
  14. data/lib/smart_core/initializer/attribute.rb +12 -5
  15. data/lib/smart_core/initializer/attribute/factory.rb +47 -27
  16. data/lib/smart_core/initializer/attribute/parameters.rb +12 -4
  17. data/lib/smart_core/initializer/configuration.rb +33 -0
  18. data/lib/smart_core/initializer/constructor.rb +35 -8
  19. data/lib/smart_core/initializer/{attribute → constructor}/definer.rb +64 -12
  20. data/lib/smart_core/initializer/dsl.rb +49 -10
  21. data/lib/smart_core/initializer/dsl/inheritance.rb +1 -0
  22. data/lib/smart_core/initializer/errors.rb +44 -0
  23. data/lib/smart_core/initializer/extensions.rb +9 -0
  24. data/lib/smart_core/initializer/extensions/abstract.rb +8 -0
  25. data/lib/smart_core/initializer/extensions/ext_init.rb +31 -0
  26. data/lib/smart_core/initializer/extensions/list.rb +74 -0
  27. data/lib/smart_core/initializer/functionality.rb +36 -0
  28. data/lib/smart_core/initializer/instance_attribute_accessing.rb +51 -0
  29. data/lib/smart_core/initializer/plugins.rb +17 -0
  30. data/lib/smart_core/initializer/plugins/abstract.rb +55 -0
  31. data/lib/smart_core/initializer/plugins/access_mixin.rb +47 -0
  32. data/lib/smart_core/initializer/plugins/registry.rb +166 -0
  33. data/lib/smart_core/initializer/plugins/registry_interface.rb +77 -0
  34. data/lib/smart_core/initializer/plugins/thy_types.rb +30 -0
  35. data/lib/smart_core/initializer/plugins/thy_types/errors.rb +11 -0
  36. data/lib/smart_core/initializer/plugins/thy_types/thy_types.rb +23 -0
  37. data/lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb +78 -0
  38. data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation.rb +12 -0
  39. data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/base.rb +9 -0
  40. data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/cast.rb +21 -0
  41. data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/valid.rb +16 -0
  42. data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/validate.rb +19 -0
  43. data/lib/smart_core/initializer/settings.rb +49 -0
  44. data/lib/smart_core/initializer/settings/duplicator.rb +20 -0
  45. data/lib/smart_core/initializer/settings/type_system.rb +69 -0
  46. data/lib/smart_core/initializer/type_system.rb +16 -0
  47. data/lib/smart_core/initializer/type_system/interop.rb +103 -0
  48. data/lib/smart_core/initializer/type_system/interop/abstract_factory.rb +70 -0
  49. data/lib/smart_core/initializer/type_system/interop/aliasing.rb +72 -0
  50. data/lib/smart_core/initializer/type_system/interop/aliasing/alias_list.rb +141 -0
  51. data/lib/smart_core/initializer/type_system/interop/operation.rb +30 -0
  52. data/lib/smart_core/initializer/type_system/registry.rb +174 -0
  53. data/lib/smart_core/initializer/type_system/registry_interface.rb +102 -0
  54. data/lib/smart_core/initializer/type_system/smart_types.rb +48 -0
  55. data/lib/smart_core/initializer/type_system/smart_types/abstract_factory.rb +72 -0
  56. data/lib/smart_core/initializer/type_system/smart_types/operation.rb +13 -0
  57. data/lib/smart_core/initializer/type_system/smart_types/operation/base.rb +8 -0
  58. data/lib/smart_core/initializer/type_system/smart_types/operation/cast.rb +16 -0
  59. data/lib/smart_core/initializer/type_system/smart_types/operation/valid.rb +16 -0
  60. data/lib/smart_core/initializer/type_system/smart_types/operation/validate.rb +16 -0
  61. data/lib/smart_core/initializer/version.rb +2 -1
  62. data/smart_initializer.gemspec +13 -9
  63. metadata +73 -17
  64. data/lib/smart_core/initializer/type_aliasing.rb +0 -50
  65. data/lib/smart_core/initializer/type_aliasing/alias_list.rb +0 -101
@@ -43,12 +43,18 @@ class SmartCore::Initializer::Attribute::Parameters
43
43
  # @since 0.1.0
44
44
  attr_reader :name
45
45
 
46
- # @return [SmartCore::Types::Primitive]
46
+ # @return [SmartCore::Initializer::TypeSystem::Interop]
47
47
  #
48
48
  # @api private
49
49
  # @since 0.1.0
50
50
  attr_reader :type
51
51
 
52
+ # @return [Class<SmartCore::Initilizer::TypeSystem::Interop>]
53
+ #
54
+ # @api private
55
+ # @since 0.1.0
56
+ attr_reader :type_system
57
+
52
58
  # @return [Symbol]
53
59
  #
54
60
  # @api private
@@ -76,7 +82,8 @@ class SmartCore::Initializer::Attribute::Parameters
76
82
  attr_reader :dynamic_options
77
83
 
78
84
  # @param name [Symbol]
79
- # @param type [SmartCore::Types::Primitive]
85
+ # @param type [SmartCore::Initializer::TypeSystem::Interop]
86
+ # @param type_system [Class<SmartCore::Initializer::TypeSystem::Interop>]
80
87
  # @param privacy [Symbol]
81
88
  # @param finalizer [SmartCore::Initializer::Attribute::AnonymousBlock/InstanceMethod]
82
89
  # @param cast [Boolean]
@@ -86,9 +93,10 @@ class SmartCore::Initializer::Attribute::Parameters
86
93
  #
87
94
  # @api private
88
95
  # @since 0.1.0
89
- def initialize(name, type, privacy, finalizer, cast, dynamic_options)
96
+ def initialize(name, type, type_system, privacy, finalizer, cast, dynamic_options)
90
97
  @name = name
91
98
  @type = type
99
+ @type_system = type_system
92
100
  @privacy = privacy
93
101
  @finalizer = finalizer
94
102
  @cast = cast
@@ -116,6 +124,6 @@ class SmartCore::Initializer::Attribute::Parameters
116
124
  ERROR_MESSAGE
117
125
  end
118
126
 
119
- defalut_value.is_a?(Proc) ? default_value.call : default_value
127
+ default_value.is_a?(Proc) ? default_value.call : default_value
120
128
  end
121
129
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'qonfig'
4
+
5
+ # @api public
6
+ # @since 0.1.0
7
+ module SmartCore::Initializer::Configuration
8
+ # @since 0.1.0
9
+ include Qonfig::Configurable
10
+
11
+ # @api public
12
+ # @since 0.1.0
13
+ extend SmartCore::Initializer::Plugins::AccessMixin
14
+
15
+ class << self
16
+ # @param setting_key [String, Symbol]
17
+ # @return [Qonfig::Settings, Any]
18
+ #
19
+ # @api private
20
+ # @since 0.1.0
21
+ def [](setting_key)
22
+ config[setting_key]
23
+ end
24
+ end
25
+
26
+ # @since 0.1.0
27
+ configuration do
28
+ setting :default_type_system, :smart_types
29
+ validate :default_type_system do |value|
30
+ SmartCore::Initializer::TypeSystem.resolve(value) rescue false
31
+ end
32
+ end
33
+ end
@@ -3,6 +3,8 @@
3
3
  # @api private
4
4
  # @since 0.1.0
5
5
  class SmartCore::Initializer::Constructor
6
+ require_relative 'constructor/definer'
7
+
6
8
  # @param klass [Class<SmartCore::Initializer>]
7
9
  # @param arguments [Array<Any>]
8
10
  # @param block [Proc, NilClass]
@@ -27,6 +29,7 @@ class SmartCore::Initializer::Constructor
27
29
  initialize_parameters(instance)
28
30
  initialize_options(instance)
29
31
  process_original_initializer(instance)
32
+ process_init_extensions(instance)
30
33
  end
31
34
  end
32
35
 
@@ -69,8 +72,8 @@ class SmartCore::Initializer::Constructor
69
72
  #
70
73
  # @api private
71
74
  # @since 0.1.0
75
+ # rubocop:disable Metrics/AbcSize
72
76
  def prevent_attribute_insufficiency
73
- required_options = klass.__options__.reject(&:has_default?).map(&:name)
74
77
  required_parameter_count = klass.__params__.size
75
78
 
76
79
  raise(
@@ -79,13 +82,23 @@ class SmartCore::Initializer::Constructor
79
82
  "(given #{parameters.size}, expected #{required_parameter_count})"
80
83
  ) unless parameters.size == required_parameter_count
81
84
 
82
- missing_options = required_options.reject { |option| options.key?(option) }
85
+ required_options = klass.__options__.reject(&:has_default?).map(&:name)
86
+ missing_options = required_options.reject { |option| options.key?(option) }
83
87
 
84
88
  raise(
85
89
  SmartCore::Initializer::OptionArgumentError,
86
90
  "Missing options: #{missing_options.join(', ')}"
87
91
  ) if missing_options.any?
92
+
93
+ possible_options = klass.__options__.map(&:name)
94
+ unknown_options = options.keys - possible_options
95
+
96
+ raise(
97
+ SmartCore::Initializer::OptionArgumentError,
98
+ "Unknown options: #{unknown_options.join(', ')}"
99
+ ) if unknown_options.any?
88
100
  end
101
+ # rubocop:enable Metrics/AbcSize
89
102
 
90
103
  # @return [Any]
91
104
  #
@@ -104,10 +117,10 @@ class SmartCore::Initializer::Constructor
104
117
  parameter_definitions = Hash[klass.__params__.zip(parameters)]
105
118
 
106
119
  parameter_definitions.each_pair do |attribute, parameter_value|
107
- parameter_value = attribute.type.cast(parameter_value) if attribute.cast?
120
+ if !attribute.type.valid?(parameter_value) && attribute.cast?
121
+ parameter_value = attribute.type.cast(parameter_value)
122
+ end
108
123
 
109
- # TODO: fail with SmartCore::Initializer::ArgumentError
110
- # (isntead of SmartCore::Types::TypeError)
111
124
  attribute.type.validate!(parameter_value)
112
125
 
113
126
  final_value = attribute.finalizer.call(parameter_value, instance)
@@ -120,19 +133,22 @@ class SmartCore::Initializer::Constructor
120
133
  #
121
134
  # @api private
122
135
  # @since 0.1.0
136
+ # rubocop:disable Metrics/AbcSize
123
137
  def initialize_options(instance)
124
138
  klass.__options__.each do |attribute|
125
139
  option_value = options.fetch(attribute.name) { attribute.default }
126
- option_value = attribute.type.cast(option_value) if attribute.cast?
127
140
 
128
- # TODO: fail with SmartCore::Initializer::ArgumentError
129
- # (isntead of SmartCore::Types::TypeError)
141
+ if !attribute.type.valid?(option_value) && attribute.cast?
142
+ option_value = attribute.type.cast(option_value)
143
+ end
144
+
130
145
  attribute.type.validate!(option_value)
131
146
 
132
147
  final_value = attribute.finalizer.call(option_value, instance)
133
148
  instance.instance_variable_set("@#{attribute.name}", final_value)
134
149
  end
135
150
  end
151
+ # rubocop:enable Metrics/AbcSize
136
152
 
137
153
  # @param instance [Any]
138
154
  # @return [void]
@@ -143,6 +159,17 @@ class SmartCore::Initializer::Constructor
143
159
  instance.send(:initialize, *arguments, &block)
144
160
  end
145
161
 
162
+ # @param instance [Any]
163
+ # @return [void]
164
+ #
165
+ # @api private
166
+ # @since 0.1.0
167
+ def process_init_extensions(instance)
168
+ klass.__init_extensions__.each do |extension|
169
+ extension.call(instance)
170
+ end
171
+ end
172
+
146
173
  # @param arguments [Array<Any>]
147
174
  # @return [Array<Array<Any>,Hash<Symbol,Any>>]
148
175
  #
@@ -2,7 +2,8 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
- class SmartCore::Initializer::Attribute::Definer
5
+ # rubocop:disable Metrics/ClassLength
6
+ class SmartCore::Initializer::Constructor::Definer
6
7
  # @param klass [Class]
7
8
  # @return [void]
8
9
  #
@@ -13,8 +14,20 @@ class SmartCore::Initializer::Attribute::Definer
13
14
  @lock = SmartCore::Engine::Lock.new
14
15
  end
15
16
 
17
+ # @param block [Proc]
18
+ # @return [void]
19
+ #
20
+ # @api private
21
+ # @since 0.1.0
22
+ def define_init_extension(block)
23
+ thread_safe do
24
+ add_init_extension(build_init_extension(block))
25
+ end
26
+ end
27
+
16
28
  # @param name [String, Symbol]
17
- # @param type [String, Symbol, SmartCore::Types::Primitive]
29
+ # @param type [String, Symbol, Any]
30
+ # @param type_system [String, Symbol]
18
31
  # @param privacy [String, Symbol]
19
32
  # @param finalize [String, Symbol, Proc]
20
33
  # @param cast [Boolean]
@@ -23,9 +36,17 @@ class SmartCore::Initializer::Attribute::Definer
23
36
  #
24
37
  # @api private
25
38
  # @since 0.1.0
26
- def define_parameter(name, type, privacy, finalize, cast, dynamic_options)
39
+ def define_parameter(name, type, type_system, privacy, finalize, cast, dynamic_options)
27
40
  thread_safe do
28
- attribute = build_attribute(name, type, privacy, finalize, cast, dynamic_options)
41
+ attribute = build_attribute(
42
+ name,
43
+ type,
44
+ type_system,
45
+ privacy,
46
+ finalize,
47
+ cast,
48
+ dynamic_options
49
+ )
29
50
  prevent_option_overlap(attribute)
30
51
  add_parameter(attribute)
31
52
  end
@@ -41,7 +62,8 @@ class SmartCore::Initializer::Attribute::Definer
41
62
  names.map do |name|
42
63
  build_attribute(
43
64
  name,
44
- SmartCore::Types::Value::Any,
65
+ klass.__initializer_settings__.generic_type_object,
66
+ klass.__initializer_settings__.type_system,
45
67
  SmartCore::Initializer::Attribute::Parameters::DEFAULT_PRIVACY_MODE,
46
68
  SmartCore::Initializer::Attribute::Parameters::DEFAULT_FINALIZER,
47
69
  SmartCore::Initializer::Attribute::Parameters::DEFAULT_CAST_BEHAVIOUR,
@@ -56,7 +78,8 @@ class SmartCore::Initializer::Attribute::Definer
56
78
  end
57
79
 
58
80
  # @param name [String, Symbol]
59
- # @param type [String, Symbol, SmartCore::Types::Primitive]
81
+ # @param type [String, Symbol, Any]
82
+ # @param type_system [String, Symbol]
60
83
  # @param privacy [String, Symbol]
61
84
  # @param finalize [String, Symbol, Proc]
62
85
  # @param cast [Boolean]
@@ -65,9 +88,17 @@ class SmartCore::Initializer::Attribute::Definer
65
88
  #
66
89
  # @api private
67
90
  # @since 0.1.0
68
- def define_option(name, type, privacy, finalize, cast, dynamic_options)
91
+ def define_option(name, type, type_system, privacy, finalize, cast, dynamic_options)
69
92
  thread_safe do
70
- attribute = build_attribute(name, type, privacy, finalize, cast, dynamic_options)
93
+ attribute = build_attribute(
94
+ name,
95
+ type,
96
+ type_system,
97
+ privacy,
98
+ finalize,
99
+ cast,
100
+ dynamic_options
101
+ )
71
102
  prevent_parameter_overlap(attribute)
72
103
  add_option(attribute)
73
104
  end
@@ -83,7 +114,8 @@ class SmartCore::Initializer::Attribute::Definer
83
114
  names.map do |name|
84
115
  build_attribute(
85
116
  name,
86
- SmartCore::Types::Value::Any,
117
+ klass.__initializer_settings__.generic_type_object,
118
+ klass.__initializer_settings__.type_system,
87
119
  SmartCore::Initializer::Attribute::Parameters::DEFAULT_PRIVACY_MODE,
88
120
  SmartCore::Initializer::Attribute::Parameters::DEFAULT_FINALIZER,
89
121
  SmartCore::Initializer::Attribute::Parameters::DEFAULT_CAST_BEHAVIOUR,
@@ -106,7 +138,8 @@ class SmartCore::Initializer::Attribute::Definer
106
138
  attr_reader :klass
107
139
 
108
140
  # @param name [String, Symbol]
109
- # @param type [String, Symbol, SmartCore::Types::Primitive]
141
+ # @param type [String, Symbol, Any]
142
+ # @param type_system [String, Symbol]
110
143
  # @param privacy [String, Symbol]
111
144
  # @param finalize [String, Symbol, Proc]
112
145
  # @param cast [Boolean]
@@ -115,12 +148,21 @@ class SmartCore::Initializer::Attribute::Definer
115
148
  #
116
149
  # @api private
117
150
  # @since 0.1.0
118
- def build_attribute(name, type, privacy, finalize, cast, dynamic_options)
151
+ def build_attribute(name, type, type_system, privacy, finalize, cast, dynamic_options)
119
152
  SmartCore::Initializer::Attribute::Factory.create(
120
- name, type, privacy, finalize, cast, dynamic_options
153
+ name, type, type_system, privacy, finalize, cast, dynamic_options
121
154
  )
122
155
  end
123
156
 
157
+ # @param block [Proc]
158
+ # @return [SmartCore::Initializer::Extensions::ExtInit]
159
+ #
160
+ # @api private
161
+ # @since 0.1.0
162
+ def build_init_extension(block)
163
+ SmartCore::Initializer::Extensions::ExtInit.new(block)
164
+ end
165
+
124
166
  # @param parameter [SmartCore::Initializer::Attribute]
125
167
  # @return [void]
126
168
  #
@@ -143,6 +185,15 @@ class SmartCore::Initializer::Attribute::Definer
143
185
  klass.send(option.privacy, option.name)
144
186
  end
145
187
 
188
+ # @param extension [SmartCore::Initializer::Extensions::ExtInit]
189
+ # @return [void]
190
+ #
191
+ # @api private
192
+ # @since 0.1.0
193
+ def add_init_extension(extension)
194
+ klass.__init_extensions__ << extension
195
+ end
196
+
146
197
  # @param parameter [SmartCore::Initializer::Attribute]
147
198
  # @return [void]
148
199
  #
@@ -178,3 +229,4 @@ class SmartCore::Initializer::Attribute::Definer
178
229
  @lock.synchronize(&block)
179
230
  end
180
231
  end
232
+ # rubocop:enable Metrics/ClassLength
@@ -13,10 +13,12 @@ module SmartCore::Initializer::DSL
13
13
  # @since 0.1.0
14
14
  def extended(base_klass)
15
15
  base_klass.instance_eval do
16
- instance_variable_set(:@__params__, SmartCore::Initializer::Attribute::List.new)
16
+ instance_variable_set(:@__params__, SmartCore::Initializer::Attribute::List.new)
17
17
  instance_variable_set(:@__options__, SmartCore::Initializer::Attribute::List.new)
18
- instance_variable_set(:@__definer__, SmartCore::Initializer::Attribute::Definer.new(self))
18
+ instance_variable_set(:@__init_extensions__, SmartCore::Initializer::Extensions::List.new)
19
+ instance_variable_set(:@__definer__, SmartCore::Initializer::Constructor::Definer.new(self))
19
20
  instance_variable_set(:@__deflock__, SmartCore::Engine::Lock.new)
21
+ instance_variable_set(:@__initializer_settings__, SmartCore::Initializer::Settings.new)
20
22
  end
21
23
  base_klass.extend(ClassMethods)
22
24
  base_klass.singleton_class.prepend(ClassInheritance)
@@ -31,15 +33,19 @@ module SmartCore::Initializer::DSL
31
33
  #
32
34
  # @api private
33
35
  # @since 0.1.0
36
+ # @version 0.3.1
34
37
  def inherited(child_klass)
35
38
  child_klass.instance_eval do
36
- instance_variable_set(:@__params__, SmartCore::Initializer::Attribute::List.new)
39
+ instance_variable_set(:@__params__, SmartCore::Initializer::Attribute::List.new)
37
40
  instance_variable_set(:@__options__, SmartCore::Initializer::Attribute::List.new)
38
- instance_variable_set(:@__definer__, SmartCore::Initializer::Attribute::Definer.new(self))
41
+ instance_variable_set(:@__init_extensions__, SmartCore::Initializer::Extensions::List.new)
42
+ instance_variable_set(:@__definer__, SmartCore::Initializer::Constructor::Definer.new(self))
39
43
  instance_variable_set(:@__deflock__, SmartCore::Engine::Lock.new)
44
+ instance_variable_set(:@__initializer_settings__, __initializer_settings__.dup)
40
45
  end
41
46
  child_klass.extend(ClassMethods)
42
47
  SmartCore::Initializer::DSL::Inheritance.inherit(base: self, child: child_klass)
48
+ child_klass.singleton_class.prepend(ClassInheritance)
43
49
  super
44
50
  end
45
51
  end
@@ -63,6 +69,14 @@ module SmartCore::Initializer::DSL
63
69
  @__options__
64
70
  end
65
71
 
72
+ # @return [SmartCore::Initializer::Extentions::List]
73
+ #
74
+ # @api private
75
+ # @since 0.1.0
76
+ def __init_extensions__
77
+ @__init_extensions__
78
+ end
79
+
66
80
  # @return [SmartCore::Initializer::Attribute::Definer]
67
81
  #
68
82
  # @api private
@@ -71,6 +85,14 @@ module SmartCore::Initializer::DSL
71
85
  @__definer__
72
86
  end
73
87
 
88
+ # @return [SmartCore::Initializer::Settings]
89
+ #
90
+ # @api private
91
+ # @since 0.1.0
92
+ def __initializer_settings__
93
+ @__initializer_settings__
94
+ end
95
+
74
96
  # @param arguments [Array]
75
97
  # @param block [Block]
76
98
  # @return [Any]
@@ -82,7 +104,7 @@ module SmartCore::Initializer::DSL
82
104
  end
83
105
 
84
106
  # @param name [String, Symbol]
85
- # @param type [String, Symbol, SmartCore::Types::Primitive]
107
+ # @param type [String, Symbol, Any]
86
108
  # @option cast [Boolean]
87
109
  # @option privacy [String, Symbol]
88
110
  # @option finalize [String, Symbol, Proc]
@@ -93,13 +115,16 @@ module SmartCore::Initializer::DSL
93
115
  # @since 0.1.0
94
116
  def param(
95
117
  name,
96
- type = SmartCore::Types::Value::Any,
118
+ type = __initializer_settings__.generic_type_object,
97
119
  privacy: SmartCore::Initializer::Attribute::Parameters::DEFAULT_PRIVACY_MODE,
98
120
  finalize: SmartCore::Initializer::Attribute::Parameters::DEFAULT_FINALIZER,
99
121
  cast: SmartCore::Initializer::Attribute::Parameters::DEFAULT_CAST_BEHAVIOUR,
122
+ type_system: __initializer_settings__.type_system,
100
123
  **dynamic_options
101
124
  )
102
- __definer__.define_parameter(name, type, privacy, finalize, cast, dynamic_options)
125
+ __definer__.define_parameter(
126
+ name, type, type_system, privacy, finalize, cast, dynamic_options
127
+ )
103
128
  end
104
129
 
105
130
  # @param names [Array<String, Symbol>]
@@ -112,10 +137,11 @@ module SmartCore::Initializer::DSL
112
137
  end
113
138
 
114
139
  # @param name [String, Symbol]
115
- # @param type [String, Symbol, SmartCore::Types::Primitive]
140
+ # @param type [String, Symbol, Any]
116
141
  # @option cast [Boolean]
117
142
  # @option privacy [String, Symbol]
118
143
  # @option finalize [String, Symbol, Proc]
144
+ # @option type_system [String, Symbol]
119
145
  # @param dynamic_options [Hash<Symbol,Any>]
120
146
  # @return [void]
121
147
  #
@@ -123,13 +149,16 @@ module SmartCore::Initializer::DSL
123
149
  # @since 0.1.0
124
150
  def option(
125
151
  name,
126
- type = SmartCore::Types::Value::Any,
152
+ type = __initializer_settings__.generic_type_object,
127
153
  privacy: SmartCore::Initializer::Attribute::Parameters::DEFAULT_PRIVACY_MODE,
128
154
  finalize: SmartCore::Initializer::Attribute::Parameters::DEFAULT_FINALIZER,
129
155
  cast: SmartCore::Initializer::Attribute::Parameters::DEFAULT_CAST_BEHAVIOUR,
156
+ type_system: __initializer_settings__.type_system,
130
157
  **dynamic_options
131
158
  )
132
- __definer__.define_option(name, type, privacy, finalize, cast, dynamic_options)
159
+ __definer__.define_option(
160
+ name, type, type_system, privacy, finalize, cast, dynamic_options
161
+ )
133
162
  end
134
163
 
135
164
  # @param names [Array<String, Symbol>]
@@ -140,5 +169,15 @@ module SmartCore::Initializer::DSL
140
169
  def options(*names)
141
170
  __definer__.define_options(*names)
142
171
  end
172
+
173
+ # @param block [Block]
174
+ # @return [void]
175
+ #
176
+ # @api public
177
+ # @since 0.1.0
178
+ def ext_init(&block)
179
+ __definer__.define_init_extension(block)
180
+ end
181
+ alias_method :extend_initialization_flow, :ext_init
143
182
  end
144
183
  end