foobara 0.0.52 → 0.0.54
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/CHANGELOG.md +6 -1
- data/projects/detached_entity/src/detached_entity_type.rb +63 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/to_type_transformer.rb +4 -0
- data/projects/entity/lib/foobara/entity.rb +3 -0
- data/projects/manifest/src/foobara/manifest/type.rb +1 -0
- data/projects/thread_parent/src/thread_parent.rb +15 -0
- data/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +5 -1
- data/projects/types/src/type/concerns/reflection.rb +5 -1
- data/projects/types/src/type.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d82a941eb5c4f5bb66363bf861fb5a31346ede04884d9653d73011b69ca0d0
|
4
|
+
data.tar.gz: f24d432c6aaafa2d19ebe123dc3b9c92c6939441873496189847c4aa64bec265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e761b11ffad8ffa40bc02c301d9b6fb83867a5983d3f050d149ddd321eed17fd4ac13b79b40c2d0b24a9d8957b6a577cea4c6d3a0da3fea507bb8a9978630268
|
7
|
+
data.tar.gz: bb2157cc0ccab23478dd3cd91b0d1d4f90349b4806077687e9864023e2b659f9f64e8895d0f57388a65a214a87c7b4a85cef684f21beb31312e9a011f71a3de0
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
## [0.0.
|
1
|
+
## [0.0.54] - 2025-01-31
|
2
|
+
|
3
|
+
- Change interface of base_type_for_manifest
|
4
|
+
|
5
|
+
## [0.0.53] - 2025-01-30
|
2
6
|
|
3
7
|
- Prefix and re-organize several model methods to facilitate type extension
|
8
|
+
- Add support for generating a manifest with detached entities based on context
|
4
9
|
|
5
10
|
## [0.0.51] - 2025-01-26
|
6
11
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Foobara
|
2
|
+
class DetachedEntityType < Types::Type
|
3
|
+
class << self
|
4
|
+
def types_requiring_conversion
|
5
|
+
@types_requiring_conversion ||= Set.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def model_base_classes_requiring_conversion
|
9
|
+
@model_base_classes_requiring_conversion ||= Set.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def type_requires_conversion?(type)
|
13
|
+
types_requiring_conversion.include?(type)
|
14
|
+
end
|
15
|
+
|
16
|
+
def model_base_class_requires_conversion?(model_base_class)
|
17
|
+
model_base_classes_requiring_conversion.include?(model_base_class)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def foobara_manifest(to_include: Set.new)
|
22
|
+
manifest = super
|
23
|
+
|
24
|
+
if detached_context?
|
25
|
+
declaration_data = manifest[:declaration_data]
|
26
|
+
if self.class.type_requires_conversion?(declaration_data[:type])
|
27
|
+
declaration_data = declaration_data.merge(type: :detached_entity)
|
28
|
+
end
|
29
|
+
|
30
|
+
if self.class.model_base_class_requires_conversion?(declaration_data[:model_base_class])
|
31
|
+
declaration_data = declaration_data.merge(model_base_class: "Foobara::DetachedEntity")
|
32
|
+
end
|
33
|
+
|
34
|
+
manifest = manifest.merge(declaration_data:)
|
35
|
+
end
|
36
|
+
|
37
|
+
manifest
|
38
|
+
end
|
39
|
+
|
40
|
+
def types_to_add_to_manifest
|
41
|
+
types = super
|
42
|
+
|
43
|
+
if detached_context?
|
44
|
+
types.delete(base_type)
|
45
|
+
types.unshift(base_type_for_manifest)
|
46
|
+
end
|
47
|
+
|
48
|
+
types
|
49
|
+
end
|
50
|
+
|
51
|
+
def base_type_for_manifest
|
52
|
+
if detached_context?
|
53
|
+
BuiltinTypes[:detached_entity]
|
54
|
+
else
|
55
|
+
super
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def detached_context?
|
60
|
+
Thread.foobara_var_get("foobara_manifest_context")&.[](:detached)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -11,6 +11,9 @@ module Foobara
|
|
11
11
|
|
12
12
|
detached_entity = Namespace.global.foobara_lookup_type!(:detached_entity)
|
13
13
|
BuiltinTypes.build_and_register!(:entity, detached_entity, nil)
|
14
|
+
|
15
|
+
DetachedEntityType.types_requiring_conversion << :entity
|
16
|
+
DetachedEntityType.model_base_classes_requiring_conversion << "Foobara::Entity"
|
14
17
|
end
|
15
18
|
|
16
19
|
def reset_all
|
@@ -19,6 +19,10 @@ class Thread
|
|
19
19
|
def foobara_var_set(...)
|
20
20
|
Thread.current.foobara_var_set(...)
|
21
21
|
end
|
22
|
+
|
23
|
+
def foobara_with_var(...)
|
24
|
+
Thread.current.foobara_with_var(...)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
attr_reader :foobara_parent
|
@@ -35,4 +39,15 @@ class Thread
|
|
35
39
|
def foobara_var_set(...)
|
36
40
|
thread_variable_set(...)
|
37
41
|
end
|
42
|
+
|
43
|
+
def foobara_with_var(key, value, &block)
|
44
|
+
old_value = foobara_var_get(key)
|
45
|
+
|
46
|
+
begin
|
47
|
+
foobara_var_set(key, value)
|
48
|
+
block.call
|
49
|
+
ensure
|
50
|
+
foobara_var_set(key, old_value)
|
51
|
+
end
|
52
|
+
end
|
38
53
|
end
|
@@ -45,7 +45,7 @@ module Foobara
|
|
45
45
|
category << processor
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
type_class.new(
|
49
49
|
strict_type_declaration,
|
50
50
|
base_type:,
|
51
51
|
# description: strict_type_declaration.is_a?(::Hash) && strict_type_declaration[:description],
|
@@ -60,6 +60,10 @@ module Foobara
|
|
60
60
|
)
|
61
61
|
end
|
62
62
|
|
63
|
+
def type_class
|
64
|
+
Types::Type
|
65
|
+
end
|
66
|
+
|
63
67
|
# TODO: test that registering a custom type sets its name
|
64
68
|
def type_name(strict_type_declaration)
|
65
69
|
"Anonymous #{strict_type_declaration[:type]} extension"
|
@@ -15,7 +15,7 @@ module Foobara
|
|
15
15
|
|
16
16
|
return if !start && registered?
|
17
17
|
|
18
|
-
to_process =
|
18
|
+
to_process = types_to_add_to_manifest
|
19
19
|
|
20
20
|
if element_types
|
21
21
|
to_process += case element_types
|
@@ -43,6 +43,10 @@ module Foobara
|
|
43
43
|
result
|
44
44
|
end
|
45
45
|
|
46
|
+
def types_to_add_to_manifest
|
47
|
+
[*base_type, *element_type, *possible_errors.map(&:error_class)]
|
48
|
+
end
|
49
|
+
|
46
50
|
def deep_types_depended_on
|
47
51
|
result = Set.new
|
48
52
|
to_process = types_depended_on
|
data/projects/types/src/type.rb
CHANGED
@@ -323,7 +323,7 @@ module Foobara
|
|
323
323
|
declaration_data:,
|
324
324
|
types_depended_on: types.sort,
|
325
325
|
possible_errors: possible_errors_manifests
|
326
|
-
).merge(description:, base_type:
|
326
|
+
).merge(description:, base_type: base_type_for_manifest&.full_type_name&.to_sym)
|
327
327
|
|
328
328
|
h.merge!(
|
329
329
|
supported_processor_manifest(to_include).merge(
|
@@ -340,6 +340,10 @@ module Foobara
|
|
340
340
|
super.merge(h)
|
341
341
|
end
|
342
342
|
|
343
|
+
def base_type_for_manifest
|
344
|
+
base_type
|
345
|
+
end
|
346
|
+
|
343
347
|
def supported_processor_manifest(to_include)
|
344
348
|
supported_casters = []
|
345
349
|
supported_transformers = []
|
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.
|
4
|
+
version: 0.0.54
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-31 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- projects/detached_entity/src/concerns/serialize.rb
|
195
195
|
- projects/detached_entity/src/concerns/types.rb
|
196
196
|
- projects/detached_entity/src/detached_entity.rb
|
197
|
+
- projects/detached_entity/src/detached_entity_type.rb
|
197
198
|
- projects/detached_entity/src/extensions/builtin_types/detached_entity.rb
|
198
199
|
- projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/hash.rb
|
199
200
|
- projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/attributes_declaration.rb
|