foobara 0.0.74 → 0.0.75
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f84e9712a618f872f8ae8a367282d409c6712a400912be08ab6662b9c78c8f3
|
4
|
+
data.tar.gz: 42fa80ddadda0b06e797a745dbcbcb4f6bd04e08ad7232c5462398396c86fc92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6257579e92b66549ceaeaf4fe7edd8b91f341f4fb487b5d7bfdc974ca9ebdf7e6648efa8a55fa8305ce1470874bd4c3af526f98b50791c6b718e171a1f002b33
|
7
|
+
data.tar.gz: 38beb4463a136f1c47e4e57b4ad513f6867562792fb0847328ec9e694da1f75b9d2eb7286318cffa54ffb2d8a28a0067ac016c8f5924fa966aa85ad902120fd8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# [0.0.75] - 2025-03-15
|
2
|
+
|
3
|
+
- Maybe a bad idea, but... add some convenience behavior to casting attributes to records:
|
4
|
+
build the record if it has an id that exists, otherwise create it
|
5
|
+
- When serializing unloaded records, load them instead of raising an error
|
6
|
+
|
1
7
|
# [0.0.74] - 2025-03-15
|
2
8
|
|
3
9
|
- fix bug where a command connector won't expose the non-global domain of a type if the command it depends on
|
@@ -8,9 +8,7 @@ module Foobara
|
|
8
8
|
# TODO: handle polymorphism? Would require iterating over the result type not the object!
|
9
9
|
# Is there maybe prior art for this in the associations stuff?
|
10
10
|
unless object.loaded?
|
11
|
-
|
12
|
-
raise "#{object} is not loaded so cannot serialize it"
|
13
|
-
# :nocov:
|
11
|
+
object.class.load(object)
|
14
12
|
end
|
15
13
|
|
16
14
|
transform(object.attributes)
|
@@ -4,10 +4,8 @@ module Foobara
|
|
4
4
|
class AtomicSerializer < SuccessSerializer
|
5
5
|
def serialize(object)
|
6
6
|
if object.is_a?(Model)
|
7
|
-
if object.is_a?(Entity) && !object.loaded?
|
8
|
-
|
9
|
-
raise "#{object} is not loaded so cannot serialize it"
|
10
|
-
# :nocov:
|
7
|
+
if object.is_a?(Entity) && !object.built? && !object.loaded?
|
8
|
+
object.class.load(object)
|
11
9
|
end
|
12
10
|
|
13
11
|
object = object.attributes
|
@@ -7,10 +7,25 @@ module Foobara
|
|
7
7
|
def build_method(attributes)
|
8
8
|
outcome = entity_class.attributes_type.process_value(attributes)
|
9
9
|
|
10
|
-
outcome.result
|
11
|
-
|
12
10
|
if outcome.success?
|
13
|
-
|
11
|
+
cast_attributes = outcome.result
|
12
|
+
|
13
|
+
primary_key_value = cast_attributes[entity_class.primary_key_attribute]
|
14
|
+
|
15
|
+
if primary_key_value
|
16
|
+
# TODO: we need a way to specify if an entity requires a primary key upon creation (guid style)
|
17
|
+
# or not (autoincrement assigned by data store style.)
|
18
|
+
# This code path was added because of following use-case: command returns attributes
|
19
|
+
# of an existing record for a result_type of the entity class. We really just want to wrap
|
20
|
+
# it in that class but we don't want to create the thing.
|
21
|
+
if entity_class.exists?(primary_key_value)
|
22
|
+
:build
|
23
|
+
else
|
24
|
+
:create
|
25
|
+
end
|
26
|
+
else
|
27
|
+
:create
|
28
|
+
end
|
14
29
|
else
|
15
30
|
# we build an instance so that it can fail a validator later. But we already know we don't want to
|
16
31
|
# persist this thing. So use build instead of create.
|
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.75
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-16 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|