foobara 0.0.141 → 0.1.1

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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +23 -0
  4. data/projects/builtin_types/lib/foobara/builtin_types.rb +1 -0
  5. data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_defaults_from_element_types_to_root.rb +9 -2
  6. data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/desugarizers/symbolize_defaults.rb +1 -1
  7. data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb +1 -1
  8. data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/desugarizers/alphabetize_required.rb +5 -5
  9. data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_required_from_element_types_to_root.rb +12 -2
  10. data/projects/builtin_types/src/builtin_types.rb +1 -1
  11. data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/class_desugarizer.rb +10 -2
  12. data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/class_type_desugarizer.rb +7 -2
  13. data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/instance_of_class_desugarizer.rb +3 -4
  14. data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/instance_of_symbol_desugarizer.rb +3 -4
  15. data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/type_declaration_validators/is_valid_class.rb +1 -1
  16. data/projects/builtin_types/src/duck/supported_validators/instance_of.rb +1 -0
  17. data/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/cast_one_of.rb +4 -3
  18. data/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +3 -3
  19. data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/desugarizers/set_size.rb +1 -1
  20. data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb +2 -4
  21. data/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb +12 -12
  22. data/projects/command/src/command_pattern_implementation/concerns/reflection.rb +4 -2
  23. data/projects/command/src/command_pattern_implementation/concerns/result_type.rb +0 -4
  24. data/projects/command_connectors/src/command_connector.rb +6 -6
  25. data/projects/command_connectors/src/command_registry.rb +7 -4
  26. data/projects/command_connectors/src/transformed_command.rb +22 -8
  27. data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +1 -0
  28. data/projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb +4 -0
  29. data/projects/common/src/error_collection.rb +1 -1
  30. data/projects/detached_entity/src/concerns/types.rb +7 -1
  31. data/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb +1 -1
  32. data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/hash_desugarizer.rb +6 -9
  33. data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/primary_key_desugarizer.rb +2 -1
  34. data/projects/domain/src/domain_module_extension.rb +12 -4
  35. data/projects/entity/src/concerns/types.rb +6 -1
  36. data/projects/foobara/lib/foobara/all.rb +4 -4
  37. data/projects/manifest/src/foobara/manifest/type.rb +11 -2
  38. data/projects/manifest/src/foobara/manifest/type_declaration.rb +46 -2
  39. data/projects/model/src/concerns/aliases.rb +8 -0
  40. data/projects/model/src/concerns/reflection.rb +2 -2
  41. data/projects/model/src/concerns/types.rb +35 -20
  42. data/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +12 -8
  43. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +1 -1
  44. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +15 -1
  45. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +7 -5
  46. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +4 -7
  47. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +0 -2
  48. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +28 -9
  49. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +8 -7
  50. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +4 -7
  51. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +14 -2
  52. data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +8 -9
  53. data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +6 -2
  54. data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +5 -2
  55. data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +8 -7
  56. data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +4 -1
  57. data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +20 -5
  58. data/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +23 -5
  59. data/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +18 -0
  60. data/projects/model_attribute_helpers/src/attribute_helpers.rb +44 -26
  61. data/projects/namespace/src/is_namespace.rb +93 -49
  62. data/projects/namespace/src/namespace/lookup_mode.rb +13 -2
  63. data/projects/namespace/src/namespace_helpers.rb +1 -0
  64. data/projects/namespace/src/prefixless_registry.rb +2 -0
  65. data/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +20 -1
  66. data/projects/persistence/src/entity_base/transaction.rb +14 -11
  67. data/projects/persistence/src/entity_base/transaction_table.rb +10 -49
  68. data/projects/persistence/src/entity_base.rb +39 -0
  69. data/projects/persistence/src/persistence.rb +4 -0
  70. data/projects/type_declarations/src/attributes.rb +15 -9
  71. data/projects/type_declarations/src/attributes_transformers/from_yaml.rb +1 -1
  72. data/projects/type_declarations/src/desugarizer_pipeline.rb +9 -0
  73. data/projects/type_declarations/src/dsl/attributes.rb +14 -5
  74. data/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +24 -4
  75. data/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +23 -9
  76. data/projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb +3 -7
  77. data/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +15 -4
  78. data/projects/type_declarations/src/handlers/extend_array_type_declaration.rb +12 -2
  79. data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/key_type_declaration_desugarizer.rb +48 -0
  80. data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb +3 -11
  81. data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/value_type_declaration_desugarizer.rb +51 -0
  82. data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration.rb +12 -2
  83. data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/dsl_desugarizer.rb +1 -1
  84. data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +17 -7
  85. data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/hash_desugarizer.rb +16 -19
  86. data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/to_type_transformer.rb +3 -6
  87. data/projects/type_declarations/src/handlers/extend_attributes_type_declaration.rb +13 -2
  88. data/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +3 -3
  89. data/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +16 -4
  90. data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +20 -6
  91. data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb +3 -9
  92. data/projects/type_declarations/src/handlers/extend_tuple_type_declaration.rb +12 -2
  93. data/projects/type_declarations/src/handlers/registered_type_declaration/to_type_transformer.rb +7 -9
  94. data/projects/type_declarations/src/handlers/registered_type_declaration.rb +22 -7
  95. data/projects/type_declarations/src/lazy_element_types/array.rb +19 -0
  96. data/projects/type_declarations/src/lazy_element_types/attributes.rb +27 -0
  97. data/projects/type_declarations/src/lazy_element_types/hash.rb +38 -0
  98. data/projects/type_declarations/src/lazy_element_types/tuple.rb +23 -0
  99. data/projects/type_declarations/src/sensitive_type_remover.rb +6 -1
  100. data/projects/type_declarations/src/sensitive_type_removers/attributes.rb +2 -0
  101. data/projects/type_declarations/src/type_builder.rb +46 -21
  102. data/projects/type_declarations/src/type_declaration.rb +295 -0
  103. data/projects/type_declarations/src/type_declaration_handler.rb +10 -11
  104. data/projects/type_declarations/src/type_declarations.rb +12 -5
  105. data/projects/types/src/type.rb +26 -4
  106. data/projects/value/src/mutator.rb +1 -4
  107. data/projects/value/src/processor/casting.rb +7 -2
  108. data/projects/value/src/processor/pipeline.rb +9 -1
  109. data/projects/value/src/processor.rb +0 -2
  110. data/projects/value/src/transformer.rb +1 -3
  111. data/projects/value/src/validator.rb +0 -2
  112. data/projects/weak_object_set/src/weak_object_set.rb +2 -0
  113. metadata +24 -21
  114. data/projects/type_declarations/src/handlers/registered_type_declaration/desugarizer_metadata_cleanup_desugarizer.rb +0 -29
  115. data/projects/type_declarations/src/handlers/registered_type_declaration/short_type_name_desugarizer.rb +0 -63
  116. data/projects/type_declarations/src/handlers/registered_type_declaration/strict_desugarizer.rb +0 -32
  117. data/projects/type_declarations/src/handlers/registered_type_declaration/strict_stringified_desugarizer.rb +0 -39
  118. data/projects/type_declarations/src/handlers/registered_type_declaration/symbol_desugarizer.rb +0 -30
  119. data/projects/type_declarations/src/handlers/registered_type_declaration/type_desugarizer.rb +0 -24
@@ -0,0 +1,295 @@
1
+ module Foobara
2
+ # Inheriting from ::Hash for now but we should remove this once all of the handlers are updated
3
+ class TypeDeclaration
4
+ attr_reader :is_strict
5
+
6
+ attr_accessor :is_duped,
7
+ :declaration_data,
8
+ :is_deep_duped,
9
+ :is_absolutified,
10
+ :reference_checked,
11
+ :type,
12
+ :base_type
13
+
14
+ # TODO: we should be able to delete absolutified opt once strict declarations
15
+ # use `:ref` instead of `{type: :ref}` format.
16
+ def initialize(declaration_data, absolutified = false, skip_reference_check = false)
17
+ if TypeDeclarations.strict?
18
+ self.is_strict = true
19
+ elsif absolutified || TypeDeclarations.strict_stringified?
20
+ self.is_absolutified = true
21
+ end
22
+
23
+ self.declaration_data = declaration_data
24
+
25
+ unless strict? || skip_reference_check
26
+ handle_symbolic_declaration
27
+ end
28
+ end
29
+
30
+ def is_strict=(value)
31
+ if value
32
+ self.is_absolutified = true
33
+ end
34
+
35
+ @is_strict = value
36
+ end
37
+
38
+ def handle_symbolic_declaration
39
+ self.reference_checked = true
40
+
41
+ if declaration_data.is_a?(::Symbol)
42
+ symbol = declaration_data
43
+ elsif declaration_data.is_a?(::String) && TypeDeclarations.stringified?
44
+ symbol = declaration_data.to_sym
45
+ end
46
+
47
+ if symbol
48
+ type = if absolutified?
49
+ Domain.current.foobara_lookup_type(symbol, mode: Namespace::LookupMode::ABSOLUTE)
50
+ else
51
+ Domain.current.foobara_lookup_type(symbol)
52
+ end
53
+
54
+ if type
55
+ unless strict?
56
+ self.declaration_data = type.full_type_symbol
57
+ end
58
+
59
+ self.type = type
60
+
61
+ self.is_strict = true
62
+ self.is_deep_duped = true
63
+ self.is_duped = true
64
+
65
+ else
66
+ if declaration_data.is_a?(::Symbol)
67
+ self.is_duped = true
68
+ self.is_deep_duped = true
69
+ end
70
+
71
+ self.declaration_data = declaration_data
72
+ end
73
+ elsif TypeDeclarations.strict_stringified?
74
+ symbolize_keys!
75
+ type_symbol = self[:type].to_sym
76
+ self[:type] = type_symbol
77
+
78
+ type = Domain.current.foobara_lookup_type(type_symbol, mode: Namespace::LookupMode::ABSOLUTE)
79
+
80
+ if type
81
+ if declaration_data.keys.size == 1
82
+ self.type = type
83
+ self.is_strict = true
84
+ self.is_deep_duped = true
85
+ self.is_duped = true
86
+ self.declaration_data = type.full_type_symbol
87
+ else
88
+ self.base_type = type
89
+ end
90
+ end
91
+ elsif declaration_data.is_a?(::Hash)
92
+ type_symbol = self[:type] || self["type"]
93
+
94
+ if type_symbol
95
+ if type_symbol.is_a?(::Symbol) || type_symbol.is_a?(::String)
96
+ type = if absolutified?
97
+ Domain.current.foobara_lookup_type(type_symbol, mode: Namespace::LookupMode::ABSOLUTE)
98
+ else
99
+ Domain.current.foobara_lookup_type(type_symbol)
100
+ end
101
+
102
+ if type
103
+ symbolize_keys!
104
+ self[:type] = type.full_type_symbol
105
+ self.is_absolutified = true
106
+
107
+ if declaration_data.keys.size == 1
108
+ self.declaration_data = type.full_type_symbol
109
+
110
+ self.type = type
111
+ self.is_strict = true
112
+ self.is_deep_duped = true
113
+ else
114
+ self.base_type = type
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ def hash?
123
+ declaration_data.is_a?(::Hash)
124
+ end
125
+
126
+ def key?(key)
127
+ declaration_data.key?(key)
128
+ end
129
+
130
+ def [](key)
131
+ declaration_data[key]
132
+ end
133
+
134
+ def array?
135
+ declaration_data.is_a?(::Array)
136
+ end
137
+
138
+ def proc?
139
+ declaration_data.is_a?(::Proc)
140
+ end
141
+
142
+ def to_proc
143
+ declaration_data
144
+ end
145
+
146
+ def size
147
+ declaration_data.size
148
+ end
149
+
150
+ def delete(key)
151
+ return unless declaration_data.key?(key)
152
+
153
+ if duped?
154
+ declaration_data.delete(key)
155
+ else
156
+ self.declaration_data = declaration_data.except(key)
157
+ self.is_duped = true
158
+ end
159
+
160
+ if strict?
161
+ self.is_strict = false
162
+ end
163
+
164
+ if absolutified? && key == :type
165
+ self.is_absolutified = false
166
+ end
167
+ end
168
+
169
+ def class?
170
+ declaration_data.is_a?(::Class)
171
+ end
172
+
173
+ def []=(key, value)
174
+ if strict?
175
+ self.is_strict = false
176
+ end
177
+
178
+ unless duped?
179
+ self.declaration_data = declaration_data.dup
180
+ self.is_duped = true
181
+ end
182
+
183
+ declaration_data[key] = value
184
+ end
185
+
186
+ def all_symbolizable_keys?
187
+ Util.all_symbolizable_keys?(declaration_data)
188
+ end
189
+
190
+ def symbolize_keys!
191
+ if duped?
192
+ declaration_data.transform_keys!(&:to_sym)
193
+ else
194
+ self.declaration_data = declaration_data.transform_keys(&:to_sym)
195
+ self.is_duped = true
196
+ end
197
+
198
+ self
199
+ end
200
+
201
+ def except(...)
202
+ parts = declaration_data.except(...)
203
+
204
+ declaration = clone_from_part(parts)
205
+ declaration.is_duped = true
206
+
207
+ if declaration.strict?
208
+ declaration.is_strict = false
209
+ end
210
+
211
+ declaration
212
+ end
213
+
214
+ def slice(...)
215
+ parts = declaration_data.slice(...)
216
+
217
+ declaration = clone_from_part(parts)
218
+ declaration.is_duped = true
219
+
220
+ if declaration.strict?
221
+ declaration.is_strict = false
222
+ end
223
+
224
+ declaration
225
+ end
226
+
227
+ def assign(other)
228
+ self.declaration_data = other.declaration_data
229
+
230
+ if absolutified? != other.absolutified?
231
+ self.is_absolutified = other.absolutified?
232
+ end
233
+
234
+ if strict? != other.strict?
235
+ self.is_strict = other.strict?
236
+ end
237
+
238
+ if duped? != other.duped?
239
+ self.is_duped = other.duped?
240
+ end
241
+
242
+ if deep_duped? != other.deep_duped?
243
+ self.is_deep_duped = other.deep_duped?
244
+ end
245
+
246
+ if other.type
247
+ self.type = other.type
248
+ end
249
+
250
+ if other.base_type
251
+ self.base_type = other.base_type
252
+ end
253
+ end
254
+
255
+ def clone
256
+ declaration = TypeDeclaration.new(declaration_data, false, true)
257
+
258
+ if strict?
259
+ declaration.is_strict = true
260
+ end
261
+
262
+ if absolutified?
263
+ declaration.is_absolutified = true
264
+ end
265
+
266
+ if type
267
+ declaration.type = type
268
+ end
269
+
270
+ if base_type
271
+ declaration.base_type = base_type
272
+ end
273
+
274
+ if reference_checked?
275
+ declaration.reference_checked = true
276
+ end
277
+
278
+ declaration
279
+ end
280
+
281
+ def clone_from_part(part)
282
+ TypeDeclaration.new(part)
283
+ end
284
+
285
+ def reference?
286
+ strict? && declaration_data.is_a?(::Symbol)
287
+ end
288
+
289
+ alias absolutified? is_absolutified
290
+ alias duped? is_duped
291
+ alias deep_duped? is_deep_duped
292
+ alias strict? is_strict
293
+ alias reference_checked? reference_checked
294
+ end
295
+ end
@@ -92,25 +92,24 @@ module Foobara
92
92
  [desugarizer, type_declaration_validator, to_type_transformer]
93
93
  end
94
94
 
95
- def process_value(raw_type_declaration)
96
- # TODO: deep_dup this again??
97
- super.tap do |type_outcome|
98
- if type_outcome.success?
99
- type_outcome.result.raw_declaration_data = raw_type_declaration
100
- end
101
- end
102
- end
103
-
104
95
  def desugarizer
105
96
  # TODO: memoize this?
106
- Value::Processor::Pipeline.new(processors: desugarizers)
97
+ DesugarizerPipeline.new(processors: desugarizers)
107
98
  end
108
99
 
109
100
  def desugarize(value)
110
- desugarizer.process_value!(value)
101
+ unless value.strict?
102
+ if desugarizer.applicable?(value)
103
+ value = desugarizer.process_value!(value)
104
+ value.is_strict = true
105
+ end
106
+ end
107
+
108
+ value
111
109
  end
112
110
 
113
111
  def type_declaration_validator
112
+ # TODO: memoize this
114
113
  Value::Processor::Pipeline.new(processors: type_declaration_validators)
115
114
  end
116
115
 
@@ -30,11 +30,14 @@ module Foobara
30
30
  end
31
31
 
32
32
  def remove_sensitive_types(strict_type_declaration)
33
- handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(strict_type_declaration)
33
+ declaration = TypeDeclaration.new(strict_type_declaration)
34
+ declaration.is_strict = true
35
+
36
+ handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(declaration)
34
37
 
35
38
  sensitive_type_remover = sensitive_type_removers[handler.class.name]
36
39
 
37
- if sensitive_type_remover
40
+ if sensitive_type_remover&.applicable?(strict_type_declaration)
38
41
  sensitive_type_remover.process_value!(strict_type_declaration)
39
42
  else
40
43
  strict_type_declaration
@@ -51,12 +54,16 @@ module Foobara
51
54
  end
52
55
 
53
56
  def sensitive_value_remover_class_for_type(type)
54
- handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(type.declaration_data)
57
+ declaration_data = type.declaration_data
58
+ declaration = TypeDeclaration.new(declaration_data)
59
+ declaration.is_strict = true
60
+
61
+ handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(declaration)
55
62
  remover_class = sensitive_value_removers[handler.class.name]
56
63
 
57
64
  unless remover_class
58
65
  # :nocov:
59
- raise "No sensitive value remover found for #{type.declaration_data}"
66
+ raise "No sensitive value remover found for #{declaration_data}"
60
67
  # :nocov:
61
68
  end
62
69
 
@@ -89,7 +96,7 @@ module Foobara
89
96
  end
90
97
 
91
98
  def stringified?
92
- foobara_manifest_context_mode == Mode::STRINGIFIED
99
+ foobara_manifest_context_mode == Mode::STRINGIFIED || strict_stringified?
93
100
  end
94
101
 
95
102
  # TODO: we should desugarize these but can't because of a bug where desugarizing entities results in creating the
@@ -21,7 +21,6 @@ module Foobara
21
21
  :element_processors,
22
22
  :structure_count,
23
23
  :is_builtin,
24
- :raw_declaration_data,
25
24
  :name,
26
25
  :target_classes,
27
26
  :description,
@@ -77,6 +76,15 @@ module Foobara
77
76
  validate_processors!
78
77
  end
79
78
 
79
+ # TODO: replace the concept of builtin? with primitive?
80
+ def primitive?
81
+ declaration_data.is_a?(::Symbol)
82
+ end
83
+
84
+ def derived?
85
+ declaration_data.is_a?(::Hash)
86
+ end
87
+
80
88
  def sensitive?
81
89
  sensitive
82
90
  end
@@ -86,11 +94,23 @@ module Foobara
86
94
  end
87
95
 
88
96
  def element_type
89
- @element_type || base_type&.element_type
97
+ type = @element_type || base_type&.element_type
98
+
99
+ if type.is_a?(::Symbol)
100
+ type = @element_type = TypeDeclarations::LazyElementTypes.const_get(type).resolve(self)
101
+ end
102
+
103
+ type
90
104
  end
91
105
 
92
106
  def element_types
93
- @element_types || base_type&.element_types
107
+ types = @element_types || base_type&.element_types
108
+
109
+ if types.is_a?(::Symbol)
110
+ types = @element_types = TypeDeclarations::LazyElementTypes.const_get(types).resolve(self)
111
+ end
112
+
113
+ types
94
114
  end
95
115
 
96
116
  def has_sensitive_types?
@@ -380,7 +400,7 @@ module Foobara
380
400
 
381
401
  if registered?
382
402
  # TODO: we should just use the symbol and nothing else in this context instead of a hash with 1 element.
383
- { type: foobara_manifest_reference.to_sym }
403
+ foobara_manifest_reference.to_sym
384
404
  elsif remove_sensitive
385
405
  TypeDeclarations.remove_sensitive_types(declaration_data)
386
406
  else
@@ -450,6 +470,8 @@ module Foobara
450
470
  super.merge(h)
451
471
  end
452
472
 
473
+ # TODO: replace the concept of builtin? with primitive? and delete this method since
474
+ # primitive? already exists.
453
475
  def builtin?
454
476
  is_builtin
455
477
  end
@@ -18,10 +18,7 @@ module Foobara
18
18
  end
19
19
 
20
20
  def process_value(value)
21
- if applicable?(value)
22
- mutate(value)
23
- end
24
-
21
+ mutate(value)
25
22
  Outcome.success(value)
26
23
  end
27
24
  end
@@ -89,8 +89,13 @@ module Foobara
89
89
  end
90
90
 
91
91
  def error_message(value)
92
- type = declaration_data[:cast_to][:type].to_s
93
- article = type =~ /^[aeiouy]/i ? "an" : "a"
92
+ type = declaration_data[:cast_to]
93
+
94
+ if type.is_a?(::Hash)
95
+ type = type[:type]
96
+ end
97
+
98
+ article = type.to_s =~ /^[aeiouy]/i ? "an" : "a"
94
99
 
95
100
  "Cannot cast #{value.inspect} to #{article} #{type}. Expected it to #{applies_message}"
96
101
  end
@@ -14,7 +14,15 @@ module Foobara
14
14
 
15
15
  def process_outcome(old_outcome)
16
16
  processors.inject(old_outcome) do |outcome, processor|
17
- processor.process_outcome(outcome)
17
+ return outcome if outcome.fatal?
18
+
19
+ value = outcome.result
20
+
21
+ if processor.applicable?(value)
22
+ processor.process_outcome(outcome)
23
+ else
24
+ outcome
25
+ end
18
26
  end
19
27
  end
20
28
 
@@ -232,8 +232,6 @@ module Foobara
232
232
 
233
233
  value = old_outcome.result
234
234
 
235
- return old_outcome unless applicable?(value)
236
-
237
235
  process_value(value).tap do |outcome|
238
236
  outcome.add_errors(old_outcome.error_collection)
239
237
  end
@@ -73,9 +73,7 @@ module Foobara
73
73
  end
74
74
 
75
75
  def process_value(value)
76
- if applicable?(value)
77
- value = transform(value)
78
- end
76
+ value = transform(value)
79
77
 
80
78
  Outcome.success(value)
81
79
  end
@@ -19,8 +19,6 @@ module Foobara
19
19
  end
20
20
 
21
21
  def process_value(value)
22
- return Outcome.success(value) unless applicable?(value)
23
-
24
22
  errors = Util.array(validation_errors(value))
25
23
 
26
24
  if errors.empty?
@@ -95,6 +95,7 @@ module Foobara
95
95
  monitor.synchronize do
96
96
  ref = ref_for(object_or_object_id)
97
97
 
98
+ # TODO: is this necessary? Why not check weakref_alive? now that we're in a mutex?
98
99
  object = begin
99
100
  ref&.__getobj__
100
101
  rescue WeakRef::RefError
@@ -122,6 +123,7 @@ module Foobara
122
123
  def each
123
124
  monitor.synchronize do
124
125
  objects.each_value do |ref|
126
+ # Is this still necessary now that we're in a mutex?
125
127
  object = begin
126
128
  ref.__getobj__
127
129
  rescue WeakRef::RefError
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.141
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-31 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal
@@ -27,44 +27,44 @@ dependencies:
27
27
  name: foobara-lru-cache
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - "~>"
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.0.2
32
+ version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - "<"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.2
39
+ version: 2.0.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: foobara-util
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.0
46
+ version: 2.0.0
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "<"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.0.0
53
+ version: 2.0.0
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: inheritable-thread-vars
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.0.1
60
+ version: 2.0.0
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - "<"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.0.1
67
+ version: 2.0.0
68
68
  description: A command-centric and discoverable software framework with a focus on
69
69
  domain concepts and abstracting away integration code
70
70
  email:
@@ -373,6 +373,7 @@ files:
373
373
  - projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
374
374
  - projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb
375
375
  - projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb
376
+ - projects/model/src/extensions/type_declarations/lazy_element_types/model.rb
376
377
  - projects/model/src/model.rb
377
378
  - projects/model/src/sensitive_type_removers/extended_model.rb
378
379
  - projects/model/src/sensitive_type_removers/model.rb
@@ -421,6 +422,7 @@ files:
421
422
  - projects/type_declarations/src/attributes_transformers/reject.rb
422
423
  - projects/type_declarations/src/caster.rb
423
424
  - projects/type_declarations/src/desugarizer.rb
425
+ - projects/type_declarations/src/desugarizer_pipeline.rb
424
426
  - projects/type_declarations/src/dsl/attributes.rb
425
427
  - projects/type_declarations/src/element_processor.rb
426
428
  - projects/type_declarations/src/error_extension.rb
@@ -430,7 +432,9 @@ files:
430
432
  - projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb
431
433
  - projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb
432
434
  - projects/type_declarations/src/handlers/extend_associative_array_type_declaration.rb
435
+ - projects/type_declarations/src/handlers/extend_associative_array_type_declaration/key_type_declaration_desugarizer.rb
433
436
  - projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb
437
+ - projects/type_declarations/src/handlers/extend_associative_array_type_declaration/value_type_declaration_desugarizer.rb
434
438
  - projects/type_declarations/src/handlers/extend_attributes_type_declaration.rb
435
439
  - projects/type_declarations/src/handlers/extend_attributes_type_declaration/dsl_desugarizer.rb
436
440
  - projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb
@@ -442,13 +446,11 @@ files:
442
446
  - projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
443
447
  - projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb
444
448
  - projects/type_declarations/src/handlers/registered_type_declaration.rb
445
- - projects/type_declarations/src/handlers/registered_type_declaration/desugarizer_metadata_cleanup_desugarizer.rb
446
- - projects/type_declarations/src/handlers/registered_type_declaration/short_type_name_desugarizer.rb
447
- - projects/type_declarations/src/handlers/registered_type_declaration/strict_desugarizer.rb
448
- - projects/type_declarations/src/handlers/registered_type_declaration/strict_stringified_desugarizer.rb
449
- - projects/type_declarations/src/handlers/registered_type_declaration/symbol_desugarizer.rb
450
449
  - projects/type_declarations/src/handlers/registered_type_declaration/to_type_transformer.rb
451
- - projects/type_declarations/src/handlers/registered_type_declaration/type_desugarizer.rb
450
+ - projects/type_declarations/src/lazy_element_types/array.rb
451
+ - projects/type_declarations/src/lazy_element_types/attributes.rb
452
+ - projects/type_declarations/src/lazy_element_types/hash.rb
453
+ - projects/type_declarations/src/lazy_element_types/tuple.rb
452
454
  - projects/type_declarations/src/processor.rb
453
455
  - projects/type_declarations/src/remove_sensitive_values_transformer.rb
454
456
  - projects/type_declarations/src/sensitive_type_remover.rb
@@ -459,6 +461,7 @@ files:
459
461
  - projects/type_declarations/src/to_type_transformer.rb
460
462
  - projects/type_declarations/src/transformer.rb
461
463
  - projects/type_declarations/src/type_builder.rb
464
+ - projects/type_declarations/src/type_declaration.rb
462
465
  - projects/type_declarations/src/type_declaration_error.rb
463
466
  - projects/type_declarations/src/type_declaration_handler.rb
464
467
  - projects/type_declarations/src/type_declaration_handler_registry.rb
@@ -535,7 +538,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
535
538
  - !ruby/object:Gem::Version
536
539
  version: '0'
537
540
  requirements: []
538
- rubygems_version: 3.6.2
541
+ rubygems_version: 3.6.9
539
542
  specification_version: 4
540
543
  summary: A command-centric and discoverable software framework with a focus on domain
541
544
  concepts and abstracting away integration code