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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +36 -5
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +63 -43
- data/README.md +227 -11
- data/Rakefile +1 -1
- data/bin/rspec +54 -0
- data/gemfiles/with_external_deps.gemfile +7 -0
- data/gemfiles/with_external_deps.gemfile.lock +102 -0
- data/gemfiles/without_external_deps.gemfile +5 -0
- data/gemfiles/without_external_deps.gemfile.lock +100 -0
- data/lib/smart_core/initializer.rb +44 -34
- data/lib/smart_core/initializer/attribute.rb +12 -5
- data/lib/smart_core/initializer/attribute/factory.rb +47 -27
- data/lib/smart_core/initializer/attribute/parameters.rb +12 -4
- data/lib/smart_core/initializer/configuration.rb +33 -0
- data/lib/smart_core/initializer/constructor.rb +35 -8
- data/lib/smart_core/initializer/{attribute → constructor}/definer.rb +64 -12
- data/lib/smart_core/initializer/dsl.rb +49 -10
- data/lib/smart_core/initializer/dsl/inheritance.rb +1 -0
- data/lib/smart_core/initializer/errors.rb +44 -0
- data/lib/smart_core/initializer/extensions.rb +9 -0
- data/lib/smart_core/initializer/extensions/abstract.rb +8 -0
- data/lib/smart_core/initializer/extensions/ext_init.rb +31 -0
- data/lib/smart_core/initializer/extensions/list.rb +74 -0
- data/lib/smart_core/initializer/functionality.rb +36 -0
- data/lib/smart_core/initializer/instance_attribute_accessing.rb +51 -0
- data/lib/smart_core/initializer/plugins.rb +17 -0
- data/lib/smart_core/initializer/plugins/abstract.rb +55 -0
- data/lib/smart_core/initializer/plugins/access_mixin.rb +47 -0
- data/lib/smart_core/initializer/plugins/registry.rb +166 -0
- data/lib/smart_core/initializer/plugins/registry_interface.rb +77 -0
- data/lib/smart_core/initializer/plugins/thy_types.rb +30 -0
- data/lib/smart_core/initializer/plugins/thy_types/errors.rb +11 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types.rb +23 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb +78 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation.rb +12 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/base.rb +9 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/cast.rb +21 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/valid.rb +16 -0
- data/lib/smart_core/initializer/plugins/thy_types/thy_types/operation/validate.rb +19 -0
- data/lib/smart_core/initializer/settings.rb +49 -0
- data/lib/smart_core/initializer/settings/duplicator.rb +20 -0
- data/lib/smart_core/initializer/settings/type_system.rb +69 -0
- data/lib/smart_core/initializer/type_system.rb +16 -0
- data/lib/smart_core/initializer/type_system/interop.rb +103 -0
- data/lib/smart_core/initializer/type_system/interop/abstract_factory.rb +70 -0
- data/lib/smart_core/initializer/type_system/interop/aliasing.rb +72 -0
- data/lib/smart_core/initializer/type_system/interop/aliasing/alias_list.rb +141 -0
- data/lib/smart_core/initializer/type_system/interop/operation.rb +30 -0
- data/lib/smart_core/initializer/type_system/registry.rb +174 -0
- data/lib/smart_core/initializer/type_system/registry_interface.rb +102 -0
- data/lib/smart_core/initializer/type_system/smart_types.rb +48 -0
- data/lib/smart_core/initializer/type_system/smart_types/abstract_factory.rb +72 -0
- data/lib/smart_core/initializer/type_system/smart_types/operation.rb +13 -0
- data/lib/smart_core/initializer/type_system/smart_types/operation/base.rb +8 -0
- data/lib/smart_core/initializer/type_system/smart_types/operation/cast.rb +16 -0
- data/lib/smart_core/initializer/type_system/smart_types/operation/valid.rb +16 -0
- data/lib/smart_core/initializer/type_system/smart_types/operation/validate.rb +16 -0
- data/lib/smart_core/initializer/version.rb +2 -1
- data/smart_initializer.gemspec +13 -9
- metadata +73 -17
- data/lib/smart_core/initializer/type_aliasing.rb +0 -50
- data/lib/smart_core/initializer/type_aliasing/alias_list.rb +0 -101
data/Rakefile
CHANGED
@@ -11,8 +11,8 @@ require 'rubocop-rake'
|
|
11
11
|
RuboCop::RakeTask.new(:rubocop) do |t|
|
12
12
|
config_path = File.expand_path(File.join('.rubocop.yml'), __dir__)
|
13
13
|
t.options = ['--config', config_path]
|
14
|
-
t.requires << 'rubocop-performance'
|
15
14
|
t.requires << 'rubocop-rspec'
|
15
|
+
t.requires << 'rubocop-performance'
|
16
16
|
t.requires << 'rubocop-rake'
|
17
17
|
end
|
18
18
|
|
data/bin/rspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
module SmartCoreInitializerRSpecRunner
|
8
|
+
expand_gemfile_path = lambda do |gemfile|
|
9
|
+
File.expand_path(File.join('..', 'gemfiles', gemfile), __dir__)
|
10
|
+
end
|
11
|
+
|
12
|
+
GEMFILES = {
|
13
|
+
with_external_deps: expand_gemfile_path.call('with_external_deps.gemfile'),
|
14
|
+
without_external_deps: expand_gemfile_path.call('without_external_deps.gemfile')
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def run!
|
19
|
+
OptionParser.new do |opts|
|
20
|
+
opts.banner = 'Usage: bin/rspec [options]'
|
21
|
+
|
22
|
+
opts.on('-w', '--with-plugins', 'Run general tests and plugin tests') do
|
23
|
+
run_with_plugin_tests!
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('-n', '--without-plugins', 'Run general tests (without plugin tests') do
|
27
|
+
run_without_plugin_tests!
|
28
|
+
end
|
29
|
+
end.parse!
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def run_with_plugin_tests!
|
35
|
+
ENV['TEST_PLUGINS'] = 'true'
|
36
|
+
ENV['FULL_TEST_COVERAGE_CHECK'] = 'true'
|
37
|
+
ENV['BUNDLE_GEMFILE'] = GEMFILES[:with_external_deps]
|
38
|
+
run_tests!
|
39
|
+
end
|
40
|
+
|
41
|
+
def run_without_plugin_tests!
|
42
|
+
ENV['BUNDLE_GEMFILE'] = GEMFILES[:without_external_deps]
|
43
|
+
run_tests!
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_tests!
|
47
|
+
require 'rubygems'
|
48
|
+
require 'bundler/setup'
|
49
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
SmartCoreInitializerRSpecRunner.run!
|
@@ -0,0 +1,102 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
smart_initializer (0.3.0)
|
5
|
+
qonfig (~> 0.24)
|
6
|
+
smart_engine (~> 0.7)
|
7
|
+
smart_types (~> 0.1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.0.3.2)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 0.7, < 2)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
18
|
+
armitage-rubocop (0.87.1.2)
|
19
|
+
rubocop (= 0.87.1)
|
20
|
+
rubocop-performance (= 1.7.0)
|
21
|
+
rubocop-rails (= 2.6.0)
|
22
|
+
rubocop-rake (= 0.5.1)
|
23
|
+
rubocop-rspec (= 1.42.0)
|
24
|
+
ast (2.4.1)
|
25
|
+
concurrent-ruby (1.1.6)
|
26
|
+
diff-lcs (1.3)
|
27
|
+
docile (1.3.2)
|
28
|
+
i18n (1.8.3)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
minitest (5.14.1)
|
31
|
+
parallel (1.19.2)
|
32
|
+
parser (2.7.1.4)
|
33
|
+
ast (~> 2.4.1)
|
34
|
+
qonfig (0.24.1)
|
35
|
+
rack (2.2.3)
|
36
|
+
rainbow (3.0.0)
|
37
|
+
rake (13.0.1)
|
38
|
+
regexp_parser (1.7.1)
|
39
|
+
rexml (3.2.4)
|
40
|
+
rspec (3.9.0)
|
41
|
+
rspec-core (~> 3.9.0)
|
42
|
+
rspec-expectations (~> 3.9.0)
|
43
|
+
rspec-mocks (~> 3.9.0)
|
44
|
+
rspec-core (3.9.2)
|
45
|
+
rspec-support (~> 3.9.3)
|
46
|
+
rspec-expectations (3.9.2)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.9.0)
|
49
|
+
rspec-mocks (3.9.1)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.9.0)
|
52
|
+
rspec-support (3.9.3)
|
53
|
+
rubocop (0.87.1)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 2.7.1.1)
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.7)
|
58
|
+
rexml
|
59
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
62
|
+
rubocop-ast (0.1.0)
|
63
|
+
parser (>= 2.7.0.1)
|
64
|
+
rubocop-performance (1.7.0)
|
65
|
+
rubocop (>= 0.82.0)
|
66
|
+
rubocop-rails (2.6.0)
|
67
|
+
activesupport (>= 4.2.0)
|
68
|
+
rack (>= 1.1)
|
69
|
+
rubocop (>= 0.82.0)
|
70
|
+
rubocop-rake (0.5.1)
|
71
|
+
rubocop
|
72
|
+
rubocop-rspec (1.42.0)
|
73
|
+
rubocop (>= 0.87.0)
|
74
|
+
ruby-progressbar (1.10.1)
|
75
|
+
simplecov (0.18.5)
|
76
|
+
docile (~> 1.1)
|
77
|
+
simplecov-html (~> 0.11)
|
78
|
+
simplecov-html (0.12.2)
|
79
|
+
smart_engine (0.7.0)
|
80
|
+
smart_types (0.1.0)
|
81
|
+
smart_engine (~> 0.6)
|
82
|
+
thread_safe (0.3.6)
|
83
|
+
thy (0.1.4)
|
84
|
+
tzinfo (1.2.7)
|
85
|
+
thread_safe (~> 0.1)
|
86
|
+
unicode-display_width (1.7.0)
|
87
|
+
zeitwerk (2.3.1)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
armitage-rubocop (~> 0.87)
|
94
|
+
bundler (~> 2.1)
|
95
|
+
rake (~> 13.0)
|
96
|
+
rspec (~> 3.9)
|
97
|
+
simplecov (~> 0.18)
|
98
|
+
smart_initializer!
|
99
|
+
thy (~> 0.1.4)
|
100
|
+
|
101
|
+
BUNDLED WITH
|
102
|
+
2.1.4
|
@@ -0,0 +1,100 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
smart_initializer (0.2.0)
|
5
|
+
qonfig (~> 0.24)
|
6
|
+
smart_engine (~> 0.6)
|
7
|
+
smart_types (~> 0.1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.0.3.1)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 0.7, < 2)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
18
|
+
armitage-rubocop (0.85.0)
|
19
|
+
rubocop (= 0.85.0)
|
20
|
+
rubocop-performance (= 1.6.1)
|
21
|
+
rubocop-rails (= 2.5.2)
|
22
|
+
rubocop-rake (= 0.5.1)
|
23
|
+
rubocop-rspec (= 1.39.0)
|
24
|
+
ast (2.4.0)
|
25
|
+
concurrent-ruby (1.1.6)
|
26
|
+
diff-lcs (1.3)
|
27
|
+
docile (1.3.2)
|
28
|
+
i18n (1.8.3)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
minitest (5.14.1)
|
31
|
+
parallel (1.19.1)
|
32
|
+
parser (2.7.1.3)
|
33
|
+
ast (~> 2.4.0)
|
34
|
+
qonfig (0.24.1)
|
35
|
+
rack (2.2.2)
|
36
|
+
rainbow (3.0.0)
|
37
|
+
rake (13.0.1)
|
38
|
+
regexp_parser (1.7.1)
|
39
|
+
rexml (3.2.4)
|
40
|
+
rspec (3.9.0)
|
41
|
+
rspec-core (~> 3.9.0)
|
42
|
+
rspec-expectations (~> 3.9.0)
|
43
|
+
rspec-mocks (~> 3.9.0)
|
44
|
+
rspec-core (3.9.2)
|
45
|
+
rspec-support (~> 3.9.3)
|
46
|
+
rspec-expectations (3.9.2)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.9.0)
|
49
|
+
rspec-mocks (3.9.1)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.9.0)
|
52
|
+
rspec-support (3.9.3)
|
53
|
+
rubocop (0.85.0)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 2.7.0.1)
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.7)
|
58
|
+
rexml
|
59
|
+
rubocop-ast (>= 0.0.3)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
62
|
+
rubocop-ast (0.0.3)
|
63
|
+
parser (>= 2.7.0.1)
|
64
|
+
rubocop-performance (1.6.1)
|
65
|
+
rubocop (>= 0.71.0)
|
66
|
+
rubocop-rails (2.5.2)
|
67
|
+
activesupport
|
68
|
+
rack (>= 1.1)
|
69
|
+
rubocop (>= 0.72.0)
|
70
|
+
rubocop-rake (0.5.1)
|
71
|
+
rubocop
|
72
|
+
rubocop-rspec (1.39.0)
|
73
|
+
rubocop (>= 0.68.1)
|
74
|
+
ruby-progressbar (1.10.1)
|
75
|
+
simplecov (0.18.5)
|
76
|
+
docile (~> 1.1)
|
77
|
+
simplecov-html (~> 0.11)
|
78
|
+
simplecov-html (0.12.2)
|
79
|
+
smart_engine (0.6.0)
|
80
|
+
smart_types (0.1.0)
|
81
|
+
smart_engine (~> 0.6)
|
82
|
+
thread_safe (0.3.6)
|
83
|
+
tzinfo (1.2.7)
|
84
|
+
thread_safe (~> 0.1)
|
85
|
+
unicode-display_width (1.7.0)
|
86
|
+
zeitwerk (2.3.0)
|
87
|
+
|
88
|
+
PLATFORMS
|
89
|
+
ruby
|
90
|
+
|
91
|
+
DEPENDENCIES
|
92
|
+
armitage-rubocop (~> 0.85)
|
93
|
+
bundler (~> 2.1)
|
94
|
+
rake (~> 13.0)
|
95
|
+
rspec (~> 3.9)
|
96
|
+
simplecov (~> 0.18)
|
97
|
+
smart_initializer!
|
98
|
+
|
99
|
+
BUNDLED WITH
|
100
|
+
2.1.4
|
@@ -6,46 +6,56 @@ require 'forwardable'
|
|
6
6
|
|
7
7
|
# @api public
|
8
8
|
# @since 0.1.0
|
9
|
-
module SmartCore
|
10
|
-
|
11
|
-
require_relative 'initializer/errors'
|
12
|
-
require_relative 'initializer/attribute'
|
13
|
-
require_relative 'initializer/constructor'
|
14
|
-
require_relative 'initializer/dsl'
|
15
|
-
require_relative 'initializer/type_aliasing'
|
16
|
-
|
9
|
+
module SmartCore
|
10
|
+
# @api public
|
17
11
|
# @since 0.1.0
|
18
|
-
|
12
|
+
module Initializer
|
13
|
+
require_relative 'initializer/version'
|
14
|
+
require_relative 'initializer/errors'
|
15
|
+
require_relative 'initializer/plugins'
|
16
|
+
require_relative 'initializer/settings'
|
17
|
+
require_relative 'initializer/configuration'
|
18
|
+
require_relative 'initializer/type_system'
|
19
|
+
require_relative 'initializer/attribute'
|
20
|
+
require_relative 'initializer/extensions'
|
21
|
+
require_relative 'initializer/constructor'
|
22
|
+
require_relative 'initializer/dsl'
|
23
|
+
require_relative 'initializer/instance_attribute_accessing'
|
24
|
+
require_relative 'initializer/functionality'
|
25
|
+
|
26
|
+
# @since 0.3.0
|
27
|
+
include SmartCore::Initializer::InstanceAttributeAccessing
|
28
|
+
|
29
|
+
class << self
|
30
|
+
# @param base_klass [Class]
|
31
|
+
# @return [void]
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
# @since 0.1.0
|
35
|
+
# @version 0.3.0
|
36
|
+
def included(base_klass)
|
37
|
+
::SmartCore::Initializer::Functionality.seed_to(base_klass)
|
38
|
+
end
|
39
|
+
end
|
19
40
|
|
20
|
-
class << self
|
21
|
-
# @param base_klass [Class]
|
22
41
|
# @return [void]
|
23
42
|
#
|
24
43
|
# @api private
|
25
44
|
# @since 0.1.0
|
26
|
-
def
|
27
|
-
base_klass.extend(SmartCore::Initializer::DSL)
|
28
|
-
end
|
45
|
+
def initialize(*); end
|
29
46
|
end
|
30
47
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
type_alias(:boolean, SmartCore::Types::Value::Boolean)
|
45
|
-
type_alias(:array, SmartCore::Types::Value::Array)
|
46
|
-
type_alias(:hash, SmartCore::Types::Value::Hash)
|
47
|
-
type_alias(:proc, SmartCore::Types::Value::Proc)
|
48
|
-
type_alias(:class, SmartCore::Types::Value::Class)
|
49
|
-
type_alias(:module, SmartCore::Types::Value::Module)
|
50
|
-
type_alias(:any, SmartCore::Types::Value::Any)
|
48
|
+
class << self
|
49
|
+
# @option type_system [String, Symbol, NilSymbol]
|
50
|
+
# @return [Module]
|
51
|
+
#
|
52
|
+
# @api public
|
53
|
+
# @since 0.1.0
|
54
|
+
# @version 0.3.0
|
55
|
+
# rubocop:disable Naming/MethodName
|
56
|
+
def Initializer(type_system: SmartCore::Initializer::Functionality::INITIAL_TYPE_SYSTEM)
|
57
|
+
SmartCore::Initializer::Functionality.includable_module(type_system: type_system)
|
58
|
+
end
|
59
|
+
# rubocop:enable Naming/MethodName
|
60
|
+
end
|
51
61
|
end
|
@@ -6,7 +6,6 @@ class SmartCore::Initializer::Attribute
|
|
6
6
|
require_relative 'attribute/parameters'
|
7
7
|
require_relative 'attribute/list'
|
8
8
|
require_relative 'attribute/finalizer'
|
9
|
-
require_relative 'attribute/definer'
|
10
9
|
require_relative 'attribute/factory'
|
11
10
|
|
12
11
|
# @since 0.1.0
|
@@ -18,12 +17,18 @@ class SmartCore::Initializer::Attribute
|
|
18
17
|
# @since 0.1.0
|
19
18
|
def_delegator :parameters, :name
|
20
19
|
|
21
|
-
# @return [SmartCore::
|
20
|
+
# @return [SmartCore::Initializer::TypeSystem::Interop]
|
22
21
|
#
|
23
22
|
# @pai private
|
24
23
|
# @since 0.1.0
|
25
24
|
def_delegator :parameters, :type
|
26
25
|
|
26
|
+
# @return [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
# @since 0.1.0
|
30
|
+
def_delegator :parameters, :type_system
|
31
|
+
|
27
32
|
# @return [Symbol]
|
28
33
|
#
|
29
34
|
# @pai private
|
@@ -55,7 +60,8 @@ class SmartCore::Initializer::Attribute
|
|
55
60
|
def_delegator :parameters, :has_default?
|
56
61
|
|
57
62
|
# @param name [Symbol]
|
58
|
-
# @param type [SmartCore::
|
63
|
+
# @param type [SmartCore::Initializer::TypeSystem::Interop]
|
64
|
+
# @param type_system [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
59
65
|
# @param privacy [Symbol]
|
60
66
|
# @param finalizer [SmartCore::Initializer::Attribute::Finalizer::AnonymousBlock/InstanceMethod]
|
61
67
|
# @param cast [Boolean]
|
@@ -64,9 +70,9 @@ class SmartCore::Initializer::Attribute
|
|
64
70
|
#
|
65
71
|
# @api private
|
66
72
|
# @since 0.1.0
|
67
|
-
def initialize(name, type, privacy, finalizer, cast, dynamic_options)
|
73
|
+
def initialize(name, type, type_system, privacy, finalizer, cast, dynamic_options)
|
68
74
|
@parameters = SmartCore::Initializer::Attribute::Parameters.new(
|
69
|
-
name, type, privacy, finalizer, cast, dynamic_options
|
75
|
+
name, type, type_system, privacy, finalizer, cast, dynamic_options
|
70
76
|
)
|
71
77
|
end
|
72
78
|
|
@@ -78,6 +84,7 @@ class SmartCore::Initializer::Attribute
|
|
78
84
|
self.class.new(
|
79
85
|
parameters.name.dup,
|
80
86
|
parameters.type,
|
87
|
+
parameters.type_system,
|
81
88
|
parameters.privacy,
|
82
89
|
parameters.finalizer.dup,
|
83
90
|
parameters.cast,
|
@@ -5,7 +5,8 @@
|
|
5
5
|
class SmartCore::Initializer::Attribute::Factory
|
6
6
|
class << self
|
7
7
|
# @param name [String, Symbol]
|
8
|
-
# @param type [String, Symbol,
|
8
|
+
# @param type [String, Symbol, Any]
|
9
|
+
# @param type_system [String, Symbol]
|
9
10
|
# @param privacy [String, Symbol]
|
10
11
|
# @param finalize [String, Symbol, Proc]
|
11
12
|
# @param cast [Boolean]
|
@@ -14,15 +15,24 @@ class SmartCore::Initializer::Attribute::Factory
|
|
14
15
|
#
|
15
16
|
# @api private
|
16
17
|
# @since 0.1.0
|
17
|
-
def create(name, type, privacy, finalize, cast, dynamic_options)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
def create(name, type, type_system, privacy, finalize, cast, dynamic_options)
|
19
|
+
prepared_name = prepare_name_param(name)
|
20
|
+
prepared_privacy = prepare_privacy_param(privacy)
|
21
|
+
prepared_finalize = prepare_finalize_param(finalize)
|
22
|
+
prepared_cast = prepare_cast_param(cast)
|
23
|
+
prepared_type_system = prepare_type_system_param(type_system)
|
24
|
+
prepared_type = prepare_type_param(type, prepared_type_system)
|
25
|
+
prepared_dynamic_options = prepare_dynamic_options_param(dynamic_options)
|
26
|
+
|
27
|
+
create_attribute(
|
28
|
+
prepared_name,
|
29
|
+
prepared_type,
|
30
|
+
prepared_type_system,
|
31
|
+
prepared_privacy,
|
32
|
+
prepared_finalize,
|
33
|
+
prepared_cast,
|
34
|
+
prepared_dynamic_options
|
35
|
+
)
|
26
36
|
end
|
27
37
|
|
28
38
|
private
|
@@ -42,23 +52,21 @@ class SmartCore::Initializer::Attribute::Factory
|
|
42
52
|
name.to_sym
|
43
53
|
end
|
44
54
|
|
45
|
-
# @param type [String, Symbol,
|
46
|
-
# @
|
55
|
+
# @param type [String, Symbol, Any]
|
56
|
+
# @param type_system [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
57
|
+
# @return [SmartCore::Initializer::TypeSystem::Interop]
|
47
58
|
#
|
48
59
|
# @api private
|
49
60
|
# @since 0.1.0
|
50
|
-
def prepare_type_param(type)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
else
|
60
|
-
type
|
61
|
-
end
|
61
|
+
def prepare_type_param(type, type_system)
|
62
|
+
type_primitive =
|
63
|
+
if type.is_a?(String) || type.is_a?(Symbol)
|
64
|
+
type_system.type_from_alias(type)
|
65
|
+
else
|
66
|
+
type
|
67
|
+
end
|
68
|
+
|
69
|
+
type_system.create(type_primitive)
|
62
70
|
end
|
63
71
|
|
64
72
|
# @param cast [Boolean]
|
@@ -127,8 +135,18 @@ class SmartCore::Initializer::Attribute::Factory
|
|
127
135
|
dynamic_options
|
128
136
|
end
|
129
137
|
|
138
|
+
# @param type_system [String, Symbol]
|
139
|
+
# @return [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
140
|
+
#
|
141
|
+
# @api private
|
142
|
+
# @since 0.1.0
|
143
|
+
def prepare_type_system_param(type_system)
|
144
|
+
SmartCore::Initializer::TypeSystem.resolve(type_system)
|
145
|
+
end
|
146
|
+
|
130
147
|
# @param name [String]
|
131
|
-
# @param type [SmartCore::
|
148
|
+
# @param type [SmartCore::Initializer::TypeSystem::Interop]
|
149
|
+
# @param type_system [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
132
150
|
# @param privacy [Symbol]
|
133
151
|
# @param finalize [SmartCore::Initializer::Attribute::Finalizer::AnonymousBlock/InstanceMethod]
|
134
152
|
# @param cast [Boolean]
|
@@ -137,8 +155,10 @@ class SmartCore::Initializer::Attribute::Factory
|
|
137
155
|
#
|
138
156
|
# @api private
|
139
157
|
# @since 0.1.0
|
140
|
-
def create_attribute(name, type, privacy, finalize, cast, dynamic_options)
|
141
|
-
SmartCore::Initializer::Attribute.new(
|
158
|
+
def create_attribute(name, type, type_system, privacy, finalize, cast, dynamic_options)
|
159
|
+
SmartCore::Initializer::Attribute.new(
|
160
|
+
name, type, type_system, privacy, finalize, cast, dynamic_options
|
161
|
+
)
|
142
162
|
end
|
143
163
|
end
|
144
164
|
end
|