lutaml-model 0.8.152 → 0.8.154
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: 6be6e9b6e0d81dbc991b1d7cda6e6a81101108775c4638f09388bd508a8e2f38
|
|
4
|
+
data.tar.gz: 4d3807bd5c51e9c5d2554bbf72f875eb2f055d214fc6efcaa670a161cf7de21e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a35214810fd059595ce1cd8ed7d8e7cbeb4d8286da37f9a3a55dfcdd923147e9d8a8b003f6a216c2237dd2cdc21e238194a5a1ac7c9b056f34e3cfae9e8b7549
|
|
7
|
+
data.tar.gz: 025c3a00a72de6a7e89a102d7b4ccfbd52f08d357f5a33a5771055330acb2eb93cba406f53e51e6cd05891171418f488775d9128d07f7752be881a99bb729a99
|
|
@@ -65,7 +65,9 @@ model_class: nil)
|
|
|
65
65
|
# nested-model classification — resolve once per rule; the
|
|
66
66
|
# per-field hash lookups dominated primitive-heavy docs.
|
|
67
67
|
plan = serialize_plan(rule)
|
|
68
|
-
if
|
|
68
|
+
if plan[:identity_type] &&
|
|
69
|
+
!value.is_a?(::Lutaml::Model::Serialize) &&
|
|
70
|
+
!value.is_a?(::Hash) && !value.is_a?(::Array)
|
|
69
71
|
return value
|
|
70
72
|
end
|
|
71
73
|
|
|
@@ -160,7 +162,13 @@ model_class: nil)
|
|
|
160
162
|
# (no custom to AND no custom from): a custom from means the
|
|
161
163
|
# wrapper constructor normalizes the value, so the raw value
|
|
162
164
|
# must still pass through it.
|
|
163
|
-
|
|
165
|
+
# No custom to_<format> serializer means the wrapper's
|
|
166
|
+
# to_<format> is the inherited identity — the raw value IS the
|
|
167
|
+
# serialized form, whatever its class (the old
|
|
168
|
+
# value.instance_of?(TypeClass) check could never match raw
|
|
169
|
+
# scalars, so every Integer/Boolean/String paid the
|
|
170
|
+
# wrap-allocate-cast ceremony).
|
|
171
|
+
if plan[:identity_type] && !value.is_a?(::Lutaml::Model::Serialize) && !value.is_a?(::Hash) && !value.is_a?(::Array)
|
|
164
172
|
return value
|
|
165
173
|
end
|
|
166
174
|
if (to_fn = plan[:to_fn])
|
|
@@ -227,9 +235,12 @@ model_class: nil)
|
|
|
227
235
|
|
|
228
236
|
serializer = ::Lutaml::Model::Type::Value
|
|
229
237
|
.format_type_serializer_for(@format, type)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
238
|
+
# Only a registered custom to_<format> serializer blocks the
|
|
239
|
+
# identity path: #to_<format>'s default is the inherited identity,
|
|
240
|
+
# so the wrapper ceremony is a no-op for every other type. (The
|
|
241
|
+
# custom FROM probe is a parse-direction concern and does not
|
|
242
|
+
# change what serialization emits.)
|
|
243
|
+
serializer && serializer[:to] ? nil : type
|
|
233
244
|
end
|
|
234
245
|
|
|
235
246
|
private
|
|
@@ -421,7 +421,37 @@ module Lutaml
|
|
|
421
421
|
self.class.cast_type!(type)
|
|
422
422
|
end
|
|
423
423
|
|
|
424
|
+
# Per-(attribute, register) memo for the dominant scalar case: the
|
|
425
|
+
# resolved type is a plain Type::Value with no custom probes, the
|
|
426
|
+
# attribute is not a collection/union/reference, and the input is a
|
|
427
|
+
# String (the shape every wire format hands over). The full cast
|
|
428
|
+
# chain resolves the same type and lands on the same
|
|
429
|
+
# `resolved_type.cast(value)` call — this skips the eight
|
|
430
|
+
# intermediate checks per value. Generation-guarded like
|
|
431
|
+
# #type's register cache: a replaced register context flushes it.
|
|
432
|
+
def fast_scalar_type(register)
|
|
433
|
+
generation = GlobalContext.context_generation
|
|
434
|
+
cache = (@fast_scalar_types ||= {}.compare_by_identity)
|
|
435
|
+
if @fast_scalar_generation != generation
|
|
436
|
+
cache.clear
|
|
437
|
+
@fast_scalar_generation = generation
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
cache[register] ||= begin
|
|
441
|
+
resolved = type(register)
|
|
442
|
+
resolved if resolved.is_a?(Class) &&
|
|
443
|
+
resolved < Lutaml::Model::Type::Value &&
|
|
444
|
+
resolved != Lutaml::Model::Type::Hash &&
|
|
445
|
+
!union? && !collection? && @options[:ref_model_class].nil? &&
|
|
446
|
+
!self.class.custom_from_probe?(resolved)
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
|
|
424
450
|
def cast_value(value, register)
|
|
451
|
+
if value.is_a?(::String) && (fast = fast_scalar_type(register))
|
|
452
|
+
return fast.cast(value)
|
|
453
|
+
end
|
|
454
|
+
|
|
425
455
|
if list_like?(value)
|
|
426
456
|
items = cast_items(value, register)
|
|
427
457
|
elsif coerce_to_collection?(value)
|
|
@@ -655,6 +655,15 @@ module Lutaml
|
|
|
655
655
|
next unless unset
|
|
656
656
|
|
|
657
657
|
default = attr.default_value(register_id, instance)
|
|
658
|
+
if raw.nil? && Lutaml::Model::Utils.uninitialized?(default)
|
|
659
|
+
# The constructor-seeded path (#1059) already wrote nil for
|
|
660
|
+
# non-defaulted attributes and marked them using-default — a
|
|
661
|
+
# nil write through the cast chain here would be pure re-work.
|
|
662
|
+
# (Sentinels and lazy collections fall through: they need the
|
|
663
|
+
# seeding branch.)
|
|
664
|
+
instance.using_default_for(name)
|
|
665
|
+
next
|
|
666
|
+
end
|
|
658
667
|
value = if Lutaml::Model::Utils.uninitialized?(default)
|
|
659
668
|
nil
|
|
660
669
|
else
|
data/lib/lutaml/model/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.154
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|