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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2864913cd9394c107229c991b761ca242a2b86dcdede5e2c18dc506c1c4694c0
4
- data.tar.gz: 185e017e5206d707e590647b0f024742b874ef41ebc4569c43867420c37c9df9
3
+ metadata.gz: 2ce26fb2ceea1f309276c6b434bb1371dad5844ac46c02f6f35cb8796e610997
4
+ data.tar.gz: 395b836af87f5d72eb9f1cfdf11605fd0709fe7030a1bfdae90895d3a200a7aa
5
5
  SHA512:
6
- metadata.gz: 76a106a02c5cce555b55fa415ba66d48bb8d55ca276f81f079ed4efd63c37bdc03157f147322475cc92a085030c1cc43129319c933a6a2c8a3c77336058e78bd
7
- data.tar.gz: 959c99953c84ed9f1113fca6fcd8c77336d01a594401008c2aa825455c8679ac39625162a1523b4b3aa4fba74e0ff738c53838a4ef7c4bb226ace70c9a5630b8
6
+ metadata.gz: a6cf896d47de2a22bec5a81a2f26c601074f8858d6259b482febaa6ec52523eb9241acd79d6e8a5d1f6d5cefcbf658e403fca39d3dc0a87113975d42befe9f6d
7
+ data.tar.gz: c46f9de89b2db21f9786b87baaf8a67f1983f36d3b91d90f51d05805462571d145d3d96e41cfd42019734cb5c8e97ae11b89c2e5336590717bcbd8b0fdc85476
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.8] - 2024-08-23
2
+
3
+ - Add a couple more entity attribute convenience helpers to commands
4
+
1
5
  ## [0.0.7] - 2024-08-21
2
6
 
3
7
  - Add Manifest::Type#builtin?
@@ -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.7
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-22 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foobara-util