foobara 0.0.7 → 0.0.8
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 +4 -0
- data/projects/command/src/command/entity_helpers.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ce26fb2ceea1f309276c6b434bb1371dad5844ac46c02f6f35cb8796e610997
|
4
|
+
data.tar.gz: 395b836af87f5d72eb9f1cfdf11605fd0709fe7030a1bfdae90895d3a200a7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6cf896d47de2a22bec5a81a2f26c601074f8858d6259b482febaa6ec52523eb9241acd79d6e8a5d1f6d5cefcbf658e403fca39d3dc0a87113975d42befe9f6d
|
7
|
+
data.tar.gz: c46f9de89b2db21f9786b87baaf8a67f1983f36d3b91d90f51d05805462571d145d3d96e41cfd42019734cb5c8e97ae11b89c2e5336590717bcbd8b0fdc85476
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,45 @@ module Foobara
|
|
3
3
|
module EntityHelpers
|
4
4
|
module_function
|
5
5
|
|
6
|
+
# Just for convenience
|
7
|
+
def attributes_for_update(entity_class)
|
8
|
+
type_declaration_for_record_aggregate_update(entity_class)
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO: we should have metadata on the entity about whether it required a primary key
|
12
|
+
# upon creation or not instead of an option here.
|
13
|
+
def attributes_for_create(entity_class, includes_primary_key: false)
|
14
|
+
attributes_type = entity_class.attributes_type
|
15
|
+
|
16
|
+
return attributes_type if includes_primary_key
|
17
|
+
|
18
|
+
declaration = attributes_type.declaration_data
|
19
|
+
# TODO: just slice out the element type declarations
|
20
|
+
declaration = Util.deep_dup(declaration)
|
21
|
+
|
22
|
+
primary_key_attribute = entity_class.primary_key_attribute
|
23
|
+
|
24
|
+
if declaration.key?(:required) && declaration[:required].include?(primary_key_attribute)
|
25
|
+
declaration[:required].delete(primary_key_attribute)
|
26
|
+
end
|
27
|
+
|
28
|
+
if declaration.key?(:defaults) && declaration[:defaults].include?(primary_key_attribute)
|
29
|
+
declaration[:defaults].delete(primary_key_attribute)
|
30
|
+
end
|
31
|
+
|
32
|
+
if declaration.key?(:element_type_declarations)
|
33
|
+
if declaration[:element_type_declarations].key?(primary_key_attribute)
|
34
|
+
declaration[:element_type_declarations].delete(primary_key_attribute)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
handler = Domain.global.foobara_type_builder.handler_for_class(
|
39
|
+
TypeDeclarations::Handlers::ExtendAttributesTypeDeclaration
|
40
|
+
)
|
41
|
+
|
42
|
+
handler.desugarize(declaration)
|
43
|
+
end
|
44
|
+
|
6
45
|
def type_declaration_for_record_aggregate_update(entity_class, initial = true)
|
7
46
|
declaration = entity_class.attributes_type.declaration_data
|
8
47
|
# TODO: just slice out the element type declarations
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foobara-util
|