smart_initializer 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -1
- data/CHANGELOG.md +29 -0
- data/Gemfile.lock +75 -61
- data/README.md +61 -7
- data/bin/console +3 -3
- data/bin/rspec +1 -1
- data/gemfiles/with_external_deps.gemfile.lock +75 -63
- data/gemfiles/without_external_deps.gemfile.lock +62 -57
- data/lib/smart_core/initializer.rb +7 -4
- data/lib/smart_core/initializer/attribute.rb +20 -2
- data/lib/smart_core/initializer/attribute/factory.rb +43 -3
- data/lib/smart_core/initializer/attribute/parameters.rb +30 -1
- data/lib/smart_core/initializer/constructor/definer.rb +48 -4
- data/lib/smart_core/initializer/dsl.rb +18 -5
- data/lib/smart_core/initializer/functionality.rb +37 -0
- data/lib/smart_core/initializer/instance_attribute_accessing.rb +51 -0
- data/lib/smart_core/initializer/plugins.rb +1 -1
- data/lib/smart_core/initializer/plugins/abstract.rb +2 -2
- data/lib/smart_core/initializer/version.rb +2 -1
- data/smart_initializer.gemspec +7 -6
- metadata +34 -20
- data/.travis.yml +0 -51
- data/lib/smart_core/initializer/configurable_module.rb +0 -27
|
@@ -1,92 +1,97 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
smart_initializer (0.
|
|
4
|
+
smart_initializer (0.3.2)
|
|
5
5
|
qonfig (~> 0.24)
|
|
6
|
-
smart_engine (~> 0.
|
|
6
|
+
smart_engine (~> 0.7)
|
|
7
7
|
smart_types (~> 0.1.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (6.
|
|
12
|
+
activesupport (6.1.1)
|
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
|
-
i18n (>=
|
|
15
|
-
minitest (
|
|
16
|
-
tzinfo (~>
|
|
17
|
-
zeitwerk (~> 2.
|
|
18
|
-
armitage-rubocop (0.
|
|
19
|
-
rubocop (= 0.
|
|
20
|
-
rubocop-performance (= 1.
|
|
21
|
-
rubocop-rails (= 2.
|
|
14
|
+
i18n (>= 1.6, < 2)
|
|
15
|
+
minitest (>= 5.1)
|
|
16
|
+
tzinfo (~> 2.0)
|
|
17
|
+
zeitwerk (~> 2.3)
|
|
18
|
+
armitage-rubocop (0.93.1)
|
|
19
|
+
rubocop (= 0.93.1)
|
|
20
|
+
rubocop-performance (= 1.8.1)
|
|
21
|
+
rubocop-rails (= 2.8.1)
|
|
22
22
|
rubocop-rake (= 0.5.1)
|
|
23
|
-
rubocop-rspec (= 1.
|
|
24
|
-
ast (2.4.
|
|
25
|
-
concurrent-ruby (1.1.
|
|
26
|
-
diff-lcs (1.
|
|
27
|
-
docile (1.3.
|
|
28
|
-
i18n (1.8.
|
|
23
|
+
rubocop-rspec (= 1.43.2)
|
|
24
|
+
ast (2.4.1)
|
|
25
|
+
concurrent-ruby (1.1.7)
|
|
26
|
+
diff-lcs (1.4.4)
|
|
27
|
+
docile (1.3.5)
|
|
28
|
+
i18n (1.8.7)
|
|
29
29
|
concurrent-ruby (~> 1.0)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
rack (2.2.2)
|
|
30
|
+
minitest (5.14.3)
|
|
31
|
+
parallel (1.20.1)
|
|
32
|
+
parser (3.0.0.0)
|
|
33
|
+
ast (~> 2.4.1)
|
|
34
|
+
qonfig (0.25.0)
|
|
35
|
+
rack (2.2.3)
|
|
37
36
|
rainbow (3.0.0)
|
|
38
|
-
rake (13.0.
|
|
37
|
+
rake (13.0.3)
|
|
38
|
+
regexp_parser (2.0.3)
|
|
39
39
|
rexml (3.2.4)
|
|
40
|
-
rspec (3.
|
|
41
|
-
rspec-core (~> 3.
|
|
42
|
-
rspec-expectations (~> 3.
|
|
43
|
-
rspec-mocks (~> 3.
|
|
44
|
-
rspec-core (3.
|
|
45
|
-
rspec-support (~> 3.
|
|
46
|
-
rspec-expectations (3.
|
|
40
|
+
rspec (3.10.0)
|
|
41
|
+
rspec-core (~> 3.10.0)
|
|
42
|
+
rspec-expectations (~> 3.10.0)
|
|
43
|
+
rspec-mocks (~> 3.10.0)
|
|
44
|
+
rspec-core (3.10.1)
|
|
45
|
+
rspec-support (~> 3.10.0)
|
|
46
|
+
rspec-expectations (3.10.1)
|
|
47
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
-
rspec-support (~> 3.
|
|
49
|
-
rspec-mocks (3.
|
|
48
|
+
rspec-support (~> 3.10.0)
|
|
49
|
+
rspec-mocks (3.10.1)
|
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
-
rspec-support (~> 3.
|
|
52
|
-
rspec-support (3.
|
|
53
|
-
rubocop (0.
|
|
54
|
-
jaro_winkler (~> 1.5.1)
|
|
51
|
+
rspec-support (~> 3.10.0)
|
|
52
|
+
rspec-support (3.10.1)
|
|
53
|
+
rubocop (0.93.1)
|
|
55
54
|
parallel (~> 1.10)
|
|
56
|
-
parser (>= 2.7.
|
|
55
|
+
parser (>= 2.7.1.5)
|
|
57
56
|
rainbow (>= 2.2.2, < 4.0)
|
|
57
|
+
regexp_parser (>= 1.8)
|
|
58
58
|
rexml
|
|
59
|
+
rubocop-ast (>= 0.6.0)
|
|
59
60
|
ruby-progressbar (~> 1.7)
|
|
60
61
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
61
|
-
rubocop-
|
|
62
|
-
|
|
63
|
-
rubocop-
|
|
64
|
-
|
|
62
|
+
rubocop-ast (1.4.0)
|
|
63
|
+
parser (>= 2.7.1.5)
|
|
64
|
+
rubocop-performance (1.8.1)
|
|
65
|
+
rubocop (>= 0.87.0)
|
|
66
|
+
rubocop-ast (>= 0.4.0)
|
|
67
|
+
rubocop-rails (2.8.1)
|
|
68
|
+
activesupport (>= 4.2.0)
|
|
65
69
|
rack (>= 1.1)
|
|
66
|
-
rubocop (>= 0.
|
|
70
|
+
rubocop (>= 0.87.0)
|
|
67
71
|
rubocop-rake (0.5.1)
|
|
68
72
|
rubocop
|
|
69
|
-
rubocop-rspec (1.
|
|
70
|
-
rubocop (
|
|
71
|
-
ruby-progressbar (1.
|
|
72
|
-
simplecov (0.
|
|
73
|
+
rubocop-rspec (1.43.2)
|
|
74
|
+
rubocop (~> 0.87)
|
|
75
|
+
ruby-progressbar (1.11.0)
|
|
76
|
+
simplecov (0.21.2)
|
|
73
77
|
docile (~> 1.1)
|
|
74
78
|
simplecov-html (~> 0.11)
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
simplecov_json_formatter (~> 0.1)
|
|
80
|
+
simplecov-html (0.12.3)
|
|
81
|
+
simplecov_json_formatter (0.1.2)
|
|
82
|
+
smart_engine (0.11.0)
|
|
77
83
|
smart_types (0.1.0)
|
|
78
84
|
smart_engine (~> 0.6)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
thread_safe (~> 0.1)
|
|
85
|
+
tzinfo (2.0.4)
|
|
86
|
+
concurrent-ruby (~> 1.0)
|
|
82
87
|
unicode-display_width (1.7.0)
|
|
83
|
-
zeitwerk (2.
|
|
88
|
+
zeitwerk (2.4.2)
|
|
84
89
|
|
|
85
90
|
PLATFORMS
|
|
86
|
-
|
|
91
|
+
x86_64-darwin-20
|
|
87
92
|
|
|
88
93
|
DEPENDENCIES
|
|
89
|
-
armitage-rubocop (~> 0.
|
|
94
|
+
armitage-rubocop (~> 0.87)
|
|
90
95
|
bundler (~> 2.1)
|
|
91
96
|
rake (~> 13.0)
|
|
92
97
|
rspec (~> 3.9)
|
|
@@ -94,4 +99,4 @@ DEPENDENCIES
|
|
|
94
99
|
smart_initializer!
|
|
95
100
|
|
|
96
101
|
BUNDLED WITH
|
|
97
|
-
2.
|
|
102
|
+
2.2.3
|
|
@@ -15,12 +15,13 @@ module SmartCore
|
|
|
15
15
|
require_relative 'initializer/plugins'
|
|
16
16
|
require_relative 'initializer/settings'
|
|
17
17
|
require_relative 'initializer/configuration'
|
|
18
|
-
require_relative 'initializer/configurable_module'
|
|
19
18
|
require_relative 'initializer/type_system'
|
|
20
19
|
require_relative 'initializer/attribute'
|
|
21
20
|
require_relative 'initializer/extensions'
|
|
22
21
|
require_relative 'initializer/constructor'
|
|
23
22
|
require_relative 'initializer/dsl'
|
|
23
|
+
require_relative 'initializer/instance_attribute_accessing'
|
|
24
|
+
require_relative 'initializer/functionality'
|
|
24
25
|
|
|
25
26
|
class << self
|
|
26
27
|
# @param base_klass [Class]
|
|
@@ -28,8 +29,9 @@ module SmartCore
|
|
|
28
29
|
#
|
|
29
30
|
# @api private
|
|
30
31
|
# @since 0.1.0
|
|
32
|
+
# @version 0.3.0
|
|
31
33
|
def included(base_klass)
|
|
32
|
-
|
|
34
|
+
::SmartCore::Initializer::Functionality.seed_to(base_klass)
|
|
33
35
|
end
|
|
34
36
|
end
|
|
35
37
|
|
|
@@ -46,9 +48,10 @@ module SmartCore
|
|
|
46
48
|
#
|
|
47
49
|
# @api public
|
|
48
50
|
# @since 0.1.0
|
|
51
|
+
# @version 0.3.0
|
|
49
52
|
# rubocop:disable Naming/MethodName
|
|
50
|
-
def Initializer(type_system: SmartCore::Initializer::
|
|
51
|
-
SmartCore::Initializer::
|
|
53
|
+
def Initializer(type_system: SmartCore::Initializer::Functionality::INITIAL_TYPE_SYSTEM)
|
|
54
|
+
SmartCore::Initializer::Functionality.includable_module(type_system: type_system)
|
|
52
55
|
end
|
|
53
56
|
# rubocop:enable Naming/MethodName
|
|
54
57
|
end
|
|
@@ -59,20 +59,34 @@ class SmartCore::Initializer::Attribute
|
|
|
59
59
|
# @since 0.1.0
|
|
60
60
|
def_delegator :parameters, :has_default?
|
|
61
61
|
|
|
62
|
+
# @return [Boolean]
|
|
63
|
+
#
|
|
64
|
+
# @api private
|
|
65
|
+
# @since 0.4.0
|
|
66
|
+
def_delegator :parameters, :read_only
|
|
67
|
+
|
|
68
|
+
# @return [String, Symbol, NilClass]
|
|
69
|
+
#
|
|
70
|
+
# @api private
|
|
71
|
+
# @since 0.4.0
|
|
72
|
+
def_delegator :parameters, :as
|
|
73
|
+
|
|
62
74
|
# @param name [Symbol]
|
|
63
75
|
# @param type [SmartCore::Initializer::TypeSystem::Interop]
|
|
64
76
|
# @param type_system [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
|
65
77
|
# @param privacy [Symbol]
|
|
66
78
|
# @param finalizer [SmartCore::Initializer::Attribute::Finalizer::AnonymousBlock/InstanceMethod]
|
|
67
79
|
# @param cast [Boolean]
|
|
80
|
+
# @param read_only [Boolean]
|
|
81
|
+
# @param as [String, Symbol, NilClass]
|
|
68
82
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
69
83
|
# @return [void]
|
|
70
84
|
#
|
|
71
85
|
# @api private
|
|
72
86
|
# @since 0.1.0
|
|
73
|
-
def initialize(name, type, type_system, privacy, finalizer, cast, dynamic_options)
|
|
87
|
+
def initialize(name, type, type_system, privacy, finalizer, cast, read_only, as, dynamic_options)
|
|
74
88
|
@parameters = SmartCore::Initializer::Attribute::Parameters.new(
|
|
75
|
-
name, type, type_system, privacy, finalizer, cast, dynamic_options
|
|
89
|
+
name, type, type_system, privacy, finalizer, cast, read_only, as, dynamic_options
|
|
76
90
|
)
|
|
77
91
|
end
|
|
78
92
|
|
|
@@ -80,6 +94,7 @@ class SmartCore::Initializer::Attribute
|
|
|
80
94
|
#
|
|
81
95
|
# @api private
|
|
82
96
|
# @since 0.1.0
|
|
97
|
+
# rubocop:disable Metrics/AbcSize
|
|
83
98
|
def dup
|
|
84
99
|
self.class.new(
|
|
85
100
|
parameters.name.dup,
|
|
@@ -88,9 +103,12 @@ class SmartCore::Initializer::Attribute
|
|
|
88
103
|
parameters.privacy,
|
|
89
104
|
parameters.finalizer.dup,
|
|
90
105
|
parameters.cast,
|
|
106
|
+
parameters.read_only,
|
|
107
|
+
parameters.as,
|
|
91
108
|
parameters.dynamic_options.dup
|
|
92
109
|
)
|
|
93
110
|
end
|
|
111
|
+
# rubocop:enable Metrics/AbcSize
|
|
94
112
|
|
|
95
113
|
private
|
|
96
114
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @api private
|
|
4
4
|
# @since 0.1.0
|
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
|
5
6
|
class SmartCore::Initializer::Attribute::Factory
|
|
6
7
|
class << self
|
|
7
8
|
# @param name [String, Symbol]
|
|
@@ -10,18 +11,22 @@ class SmartCore::Initializer::Attribute::Factory
|
|
|
10
11
|
# @param privacy [String, Symbol]
|
|
11
12
|
# @param finalize [String, Symbol, Proc]
|
|
12
13
|
# @param cast [Boolean]
|
|
14
|
+
# @param read_only [Boolean]
|
|
15
|
+
# @param as [String, Symbol, NilClass]
|
|
13
16
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
14
17
|
# @return [SmartCore::Initializer::Attribute]
|
|
15
18
|
#
|
|
16
19
|
# @api private
|
|
17
20
|
# @since 0.1.0
|
|
18
|
-
def create(name, type, type_system, privacy, finalize, cast, dynamic_options)
|
|
21
|
+
def create(name, type, type_system, privacy, finalize, cast, read_only, as, dynamic_options)
|
|
19
22
|
prepared_name = prepare_name_param(name)
|
|
20
23
|
prepared_privacy = prepare_privacy_param(privacy)
|
|
21
24
|
prepared_finalize = prepare_finalize_param(finalize)
|
|
22
25
|
prepared_cast = prepare_cast_param(cast)
|
|
23
26
|
prepared_type_system = prepare_type_system_param(type_system)
|
|
24
27
|
prepared_type = prepare_type_param(type, prepared_type_system)
|
|
28
|
+
prepared_read_only = prepare_read_only_param(read_only)
|
|
29
|
+
prepared_as = preapre_as_param(as)
|
|
25
30
|
prepared_dynamic_options = prepare_dynamic_options_param(dynamic_options)
|
|
26
31
|
|
|
27
32
|
create_attribute(
|
|
@@ -31,6 +36,8 @@ class SmartCore::Initializer::Attribute::Factory
|
|
|
31
36
|
prepared_privacy,
|
|
32
37
|
prepared_finalize,
|
|
33
38
|
prepared_cast,
|
|
39
|
+
prepared_read_only,
|
|
40
|
+
prepared_as,
|
|
34
41
|
prepared_dynamic_options
|
|
35
42
|
)
|
|
36
43
|
end
|
|
@@ -118,6 +125,36 @@ class SmartCore::Initializer::Attribute::Factory
|
|
|
118
125
|
SmartCore::Initializer::Attribute::Finalizer.create(finalize)
|
|
119
126
|
end
|
|
120
127
|
|
|
128
|
+
# @param read_only [Boolean]
|
|
129
|
+
# @return [Boolean]
|
|
130
|
+
#
|
|
131
|
+
# @api private
|
|
132
|
+
# @since 0.4.0
|
|
133
|
+
def prepare_read_only_param(read_only)
|
|
134
|
+
unless read_only.is_a?(FalseClass) || read_only.is_a?(TrueClass)
|
|
135
|
+
raise(SmartCore::Initializer::ArgumentError, <<~ERROR_MESSAGE)
|
|
136
|
+
:read_only attribute should be a type of boolean
|
|
137
|
+
ERROR_MESSAGE
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
read_only
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# @param [String, Symbol, NilClass]
|
|
144
|
+
# @return [String, Symbol, NilClass]
|
|
145
|
+
#
|
|
146
|
+
# @api private
|
|
147
|
+
# @since 0.4.0
|
|
148
|
+
def preapre_as_param(as)
|
|
149
|
+
unless as.is_a?(NilClass) || as.is_a?(String) || as.is_a?(Symbol)
|
|
150
|
+
raise(SmartCore::Initializer::ArgumentError, <<~ERROR_MESSAGE)
|
|
151
|
+
Attribute alias should be a type of String or Symbol
|
|
152
|
+
ERROR_MESSAGE
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
as
|
|
156
|
+
end
|
|
157
|
+
|
|
121
158
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
122
159
|
# @return [Hash<Symbol,Any>]
|
|
123
160
|
#
|
|
@@ -155,10 +192,13 @@ class SmartCore::Initializer::Attribute::Factory
|
|
|
155
192
|
#
|
|
156
193
|
# @api private
|
|
157
194
|
# @since 0.1.0
|
|
158
|
-
|
|
195
|
+
# rubocop:disable Layout/LineLength
|
|
196
|
+
def create_attribute(name, type, type_system, privacy, finalize, cast, read_only, as, dynamic_options)
|
|
159
197
|
SmartCore::Initializer::Attribute.new(
|
|
160
|
-
name, type, type_system, privacy, finalize, cast, dynamic_options
|
|
198
|
+
name, type, type_system, privacy, finalize, cast, read_only, as, dynamic_options
|
|
161
199
|
)
|
|
162
200
|
end
|
|
201
|
+
# rubocop:enable Layout/LineLength
|
|
163
202
|
end
|
|
164
203
|
end
|
|
204
|
+
# rubocop:enable Metrics/ClassLength
|
|
@@ -37,6 +37,18 @@ class SmartCore::Initializer::Attribute::Parameters
|
|
|
37
37
|
# @since 0.1.0
|
|
38
38
|
DEFAULT_DYNAMIC_OPTIONS = {}.freeze
|
|
39
39
|
|
|
40
|
+
# @return [Boolean]
|
|
41
|
+
#
|
|
42
|
+
# @api private
|
|
43
|
+
# @since 0.4.0
|
|
44
|
+
DEFAULT_READ_ONLY = true
|
|
45
|
+
|
|
46
|
+
# @return [NilClass]
|
|
47
|
+
#
|
|
48
|
+
# @api private
|
|
49
|
+
# @since 0.4.0
|
|
50
|
+
DEFAULT_AS = nil
|
|
51
|
+
|
|
40
52
|
# @return [Symbol]
|
|
41
53
|
#
|
|
42
54
|
# @api private
|
|
@@ -81,25 +93,42 @@ class SmartCore::Initializer::Attribute::Parameters
|
|
|
81
93
|
# @since 0.1.0
|
|
82
94
|
attr_reader :dynamic_options
|
|
83
95
|
|
|
96
|
+
# @return [Boolean]
|
|
97
|
+
#
|
|
98
|
+
# @api private
|
|
99
|
+
# @since 0.4.0
|
|
100
|
+
attr_reader :read_only
|
|
101
|
+
|
|
102
|
+
# @return [String, Symbol, NilClass]
|
|
103
|
+
#
|
|
104
|
+
# @api private
|
|
105
|
+
# @since 0.4.0
|
|
106
|
+
attr_reader :as
|
|
107
|
+
|
|
84
108
|
# @param name [Symbol]
|
|
85
109
|
# @param type [SmartCore::Initializer::TypeSystem::Interop]
|
|
86
110
|
# @param type_system [Class<SmartCore::Initializer::TypeSystem::Interop>]
|
|
87
111
|
# @param privacy [Symbol]
|
|
88
112
|
# @param finalizer [SmartCore::Initializer::Attribute::AnonymousBlock/InstanceMethod]
|
|
89
113
|
# @param cast [Boolean]
|
|
114
|
+
# @param read_only [Boolean]
|
|
115
|
+
# @param as [NilClass, Symbol, String]
|
|
90
116
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
91
117
|
# - :default - default value (Proc value will be called)
|
|
92
118
|
# @return [void]
|
|
93
119
|
#
|
|
94
120
|
# @api private
|
|
95
121
|
# @since 0.1.0
|
|
96
|
-
|
|
122
|
+
# @version 0.4.0
|
|
123
|
+
def initialize(name, type, type_system, privacy, finalizer, cast, read_only, as, dynamic_options)
|
|
97
124
|
@name = name
|
|
98
125
|
@type = type
|
|
99
126
|
@type_system = type_system
|
|
100
127
|
@privacy = privacy
|
|
101
128
|
@finalizer = finalizer
|
|
102
129
|
@cast = cast
|
|
130
|
+
@read_only = read_only
|
|
131
|
+
@as = as
|
|
103
132
|
@dynamic_options = dynamic_options
|
|
104
133
|
end
|
|
105
134
|
|
|
@@ -31,12 +31,24 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
31
31
|
# @param privacy [String, Symbol]
|
|
32
32
|
# @param finalize [String, Symbol, Proc]
|
|
33
33
|
# @param cast [Boolean]
|
|
34
|
+
# @param read_only [Boolean]
|
|
35
|
+
# @param as [String, Symbol, NilClass]
|
|
34
36
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
35
37
|
# @return [void]
|
|
36
38
|
#
|
|
37
39
|
# @api private
|
|
38
40
|
# @since 0.1.0
|
|
39
|
-
def define_parameter(
|
|
41
|
+
def define_parameter(
|
|
42
|
+
name,
|
|
43
|
+
type,
|
|
44
|
+
type_system,
|
|
45
|
+
privacy,
|
|
46
|
+
finalize,
|
|
47
|
+
cast,
|
|
48
|
+
read_only,
|
|
49
|
+
as,
|
|
50
|
+
dynamic_options
|
|
51
|
+
)
|
|
40
52
|
thread_safe do
|
|
41
53
|
attribute = build_attribute(
|
|
42
54
|
name,
|
|
@@ -45,6 +57,8 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
45
57
|
privacy,
|
|
46
58
|
finalize,
|
|
47
59
|
cast,
|
|
60
|
+
read_only,
|
|
61
|
+
as,
|
|
48
62
|
dynamic_options
|
|
49
63
|
)
|
|
50
64
|
prevent_option_overlap(attribute)
|
|
@@ -67,6 +81,8 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
67
81
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_PRIVACY_MODE,
|
|
68
82
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_FINALIZER,
|
|
69
83
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_CAST_BEHAVIOUR,
|
|
84
|
+
SmartCore::Initializer::Attribute::Parameters::DEFAULT_READ_ONLY,
|
|
85
|
+
SmartCore::Initializer::Attribute::Parameters::DEFAULT_AS,
|
|
70
86
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_DYNAMIC_OPTIONS.dup
|
|
71
87
|
).tap do |attribute|
|
|
72
88
|
prevent_option_overlap(attribute)
|
|
@@ -83,12 +99,24 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
83
99
|
# @param privacy [String, Symbol]
|
|
84
100
|
# @param finalize [String, Symbol, Proc]
|
|
85
101
|
# @param cast [Boolean]
|
|
102
|
+
# @param read_only [Boolean]
|
|
103
|
+
# @param as [String, Symbol, NilClass]
|
|
86
104
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
87
105
|
# @return [void]
|
|
88
106
|
#
|
|
89
107
|
# @api private
|
|
90
108
|
# @since 0.1.0
|
|
91
|
-
def define_option(
|
|
109
|
+
def define_option(
|
|
110
|
+
name,
|
|
111
|
+
type,
|
|
112
|
+
type_system,
|
|
113
|
+
privacy,
|
|
114
|
+
finalize,
|
|
115
|
+
cast,
|
|
116
|
+
read_only,
|
|
117
|
+
as,
|
|
118
|
+
dynamic_options
|
|
119
|
+
)
|
|
92
120
|
thread_safe do
|
|
93
121
|
attribute = build_attribute(
|
|
94
122
|
name,
|
|
@@ -97,6 +125,8 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
97
125
|
privacy,
|
|
98
126
|
finalize,
|
|
99
127
|
cast,
|
|
128
|
+
read_only,
|
|
129
|
+
as,
|
|
100
130
|
dynamic_options
|
|
101
131
|
)
|
|
102
132
|
prevent_parameter_overlap(attribute)
|
|
@@ -119,6 +149,8 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
119
149
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_PRIVACY_MODE,
|
|
120
150
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_FINALIZER,
|
|
121
151
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_CAST_BEHAVIOUR,
|
|
152
|
+
SmartCore::Initializer::Attribute::Parameters::DEFAULT_READ_ONLY,
|
|
153
|
+
SmartCore::Initializer::Attribute::Parameters::DEFAULT_AS,
|
|
122
154
|
SmartCore::Initializer::Attribute::Parameters::DEFAULT_DYNAMIC_OPTIONS.dup
|
|
123
155
|
).tap do |attribute|
|
|
124
156
|
prevent_parameter_overlap(attribute)
|
|
@@ -143,14 +175,26 @@ class SmartCore::Initializer::Constructor::Definer
|
|
|
143
175
|
# @param privacy [String, Symbol]
|
|
144
176
|
# @param finalize [String, Symbol, Proc]
|
|
145
177
|
# @param cast [Boolean]
|
|
178
|
+
# @param read_only [Boolean]
|
|
179
|
+
# @param as [String, Symbol, NilClass]
|
|
146
180
|
# @param dynamic_options [Hash<Symbol,Any>]
|
|
147
181
|
# @return [SmartCore::Initializer::Attribute]
|
|
148
182
|
#
|
|
149
183
|
# @api private
|
|
150
184
|
# @since 0.1.0
|
|
151
|
-
def build_attribute(
|
|
185
|
+
def build_attribute(
|
|
186
|
+
name,
|
|
187
|
+
type,
|
|
188
|
+
type_system,
|
|
189
|
+
privacy,
|
|
190
|
+
finalize,
|
|
191
|
+
cast,
|
|
192
|
+
read_only,
|
|
193
|
+
as,
|
|
194
|
+
dynamic_options
|
|
195
|
+
)
|
|
152
196
|
SmartCore::Initializer::Attribute::Factory.create(
|
|
153
|
-
name, type, type_system, privacy, finalize, cast, dynamic_options
|
|
197
|
+
name, type, type_system, privacy, finalize, cast, read_only, as, dynamic_options
|
|
154
198
|
)
|
|
155
199
|
end
|
|
156
200
|
|