foobara 0.0.52 → 0.0.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -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: 6f36fa530b7c550b95ee9f580590ad68e18700e80048746fb734078ea0e9744e
|
4
|
+
data.tar.gz: 1454b5d06e3be5c3be8b9cfee10b6e598b71ad74f409c7f09d2a66427f71f3a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a238d0b3ba1366f67a0edee344a7f0228367b56a0c45eabe230603310a4b36b9f13b765382907a9e8c72533f0ec18af6f1b956e575a0c79bffe08e036de3097
|
7
|
+
data.tar.gz: 99b3b4c279bc4104fc1faefda279bf4fadcae8ee57975655dec120f17ce5980fda6b2dccf1476e00df20460e3a091dba56f5c00afdc4907bdf62c374feddee78
|
data/CHANGELOG.md
CHANGED
@@ -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)
|
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&.full_type_name&.to_sym
|
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.53
|
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
|