foobara 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2415af0fac9d64a2075b934b81e2949ca672135419cd3c8dad6ee7655b449288
4
- data.tar.gz: 5a775144eb8d9073d6d9dcaf25590004fab2782de345438354b0b386b53d83ec
3
+ metadata.gz: 2ce26fb2ceea1f309276c6b434bb1371dad5844ac46c02f6f35cb8796e610997
4
+ data.tar.gz: 395b836af87f5d72eb9f1cfdf11605fd0709fe7030a1bfdae90895d3a200a7aa
5
5
  SHA512:
6
- metadata.gz: 43c26a3672bee00ffd4cb8a1939bf87194274a61f4f9e824bce378cbb216edb7b4cef85a84fd6d1695448311302e9a6db41370666c3c82f898c174e180b9835f
7
- data.tar.gz: 1944745066fca3464cb6e4a733a091ab982c2cdd8d38b5fae2ac877ffa2a0cff61990df339d5e49fa8e08274970a84812a688d35595ec3ee81c3155be6bcbc52
6
+ metadata.gz: a6cf896d47de2a22bec5a81a2f26c601074f8858d6259b482febaa6ec52523eb9241acd79d6e8a5d1f6d5cefcbf658e403fca39d3dc0a87113975d42befe9f6d
7
+ data.tar.gz: c46f9de89b2db21f9786b87baaf8a67f1983f36d3b91d90f51d05805462571d145d3d96e41cfd42019734cb5c8e97ae11b89c2e5336590717bcbd8b0fdc85476
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.8] - 2024-08-23
2
+
3
+ - Add a couple more entity attribute convenience helpers to commands
4
+
5
+ ## [0.0.7] - 2024-08-21
6
+
7
+ - Add Manifest::Type#builtin?
8
+
1
9
  ## [0.0.6] - 2024-08-21
2
10
 
3
11
  - Give a way to check if a type is builtin by reference
@@ -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
@@ -81,6 +81,10 @@ module Foobara
81
81
  def full_type_name
82
82
  scoped_full_name
83
83
  end
84
+
85
+ def builtin?
86
+ BuiltinTypes.builtin_reference?(reference)
87
+ end
84
88
  end
85
89
  end
86
90
  end
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.6
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