foobara 0.0.7 → 0.0.9

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: da90f5634c4dd8b25e3e4025aba385db5a05fb905de0eab32a87dfc75758fbb5
4
+ data.tar.gz: 558ce219e510e8dc3fa21c625d2c0350efe32636114015d070cbfcb07818b133
5
5
  SHA512:
6
- metadata.gz: 76a106a02c5cce555b55fa415ba66d48bb8d55ca276f81f079ed4efd63c37bdc03157f147322475cc92a085030c1cc43129319c933a6a2c8a3c77336058e78bd
7
- data.tar.gz: 959c99953c84ed9f1113fca6fcd8c77336d01a594401008c2aa825455c8679ac39625162a1523b4b3aa4fba74e0ff738c53838a4ef7c4bb226ace70c9a5630b8
6
+ metadata.gz: 9385c980625d21deee50b0bb88ecaf9b9fcea1557c2fe8effc162a33ea465e914a6f3f4fb21d373f322e7939ad6048aaf0e15c3081de3412f01e185cd07c02c1
7
+ data.tar.gz: 349e0c8bb94463e29c7b1515b0fa1add2aca04b1866262c45fa3a9345d9fb16068717df11c1e57cb55b47c4e2dc4dfffc56319bc2cb1840abc3d4e8c4fcc1c7b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.9] - 2024-09-11
2
+
3
+ - Add CommandRegistry#size
4
+
5
+ ## [0.0.8] - 2024-08-23
6
+
7
+ - Add a couple more entity attribute convenience helpers to commands
8
+
1
9
  ## [0.0.7] - 2024-08-21
2
10
 
3
11
  - 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
@@ -253,5 +253,9 @@ module Foobara
253
253
  def each_transformed_command_class(&)
254
254
  foobara_all_command.map(&:transformed_command_class).each(&)
255
255
  end
256
+
257
+ def size
258
+ foobara_all_command.size
259
+ end
256
260
  end
257
261
  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.7
4
+ version: 0.0.9
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-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foobara-util
@@ -427,7 +427,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
427
427
  - !ruby/object:Gem::Version
428
428
  version: '0'
429
429
  requirements: []
430
- rubygems_version: 3.4.10
430
+ rubygems_version: 3.5.18
431
431
  signing_key:
432
432
  specification_version: 4
433
433
  summary: Implements command pattern for encapsulating and managing domain complexity