lutaml-model 0.8.79 → 0.8.81
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 +4 -4
- data/lib/lutaml/key_value/transform.rb +5 -3
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/plan_hydrator.rb +6 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75aa028ab12c011d2d3c90b27d176d7096bcb7f0b09dbb521adf01d79dba8df1
|
|
4
|
+
data.tar.gz: 523a5d23381afdfb840d7256855ea6e51ca04377dee765d5d215764bd4967af0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a2723bfe0a8f6ef1049b5b5d3c5e987832f0397a12fc5f96b57bf0b74b0c2aeb5b9797d89591665fb2dd96f05724a4dcb764437ff332efc3ce2f4c484f79360
|
|
7
|
+
data.tar.gz: a3812ee1c47c9633617dc07e8cfc2ed8cd102279039c4f76389d1dc490f1eaad07f3351bba192daefbf37d7f2132b72f84a036d70890c7e6a4d87fb65591a322
|
|
@@ -206,14 +206,16 @@ module Lutaml
|
|
|
206
206
|
def kv_group_build(rows, doc, format, register, options)
|
|
207
207
|
setters = []
|
|
208
208
|
children = []
|
|
209
|
-
|
|
209
|
+
# Lazy: the present-key hot path never pushes, and this runs
|
|
210
|
+
# once per hydrated model instance.
|
|
211
|
+
absent = nil
|
|
210
212
|
rows.each do |rule, attr, kind, type, child_rows, child_register|
|
|
211
213
|
# One hash pass per row: fetch with a sentinel distinguishes
|
|
212
214
|
# absent keys from present-nil values (both read as nil), so
|
|
213
215
|
# the separate string_or_symbol_key? probe goes away.
|
|
214
216
|
v = Lutaml::Model::Utils.fetch_str_or_sym(doc, rule.name, MISSING)
|
|
215
217
|
if v.equal?(MISSING)
|
|
216
|
-
absent << rule
|
|
218
|
+
(absent ||= []) << rule
|
|
217
219
|
next
|
|
218
220
|
end
|
|
219
221
|
|
|
@@ -256,7 +258,7 @@ module Lutaml
|
|
|
256
258
|
end
|
|
257
259
|
instance = model_class.new(lutaml_register: register)
|
|
258
260
|
setters.each { |name, value| instance.public_send(name, value) }
|
|
259
|
-
absent
|
|
261
|
+
absent&.each do |rule|
|
|
260
262
|
process_mapping_rule(doc, instance, format, rule, options, nil)
|
|
261
263
|
end
|
|
262
264
|
children.each do |child|
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -107,7 +107,9 @@ module Lutaml
|
|
|
107
107
|
kwargs = {}
|
|
108
108
|
children = []
|
|
109
109
|
delegates = []
|
|
110
|
-
|
|
110
|
+
# Lazy: models without multi-spelling rows never touch it, and
|
|
111
|
+
# the block-backed Hash is a fresh object per hydrated row.
|
|
112
|
+
spellings = nil
|
|
111
113
|
row_tags = plan[:row_tags]
|
|
112
114
|
plan[:rows].each_with_index do |(rule, attr, kind, spelling, delegate), idx|
|
|
113
115
|
tag = row_tags&.[](idx)
|
|
@@ -174,6 +176,7 @@ module Lutaml
|
|
|
174
176
|
assign(kwargs, delegates, delegate, rule, attr, values)
|
|
175
177
|
end
|
|
176
178
|
when :spelling
|
|
179
|
+
spellings ||= Hash.new { |h, k| h[k] = [] }
|
|
177
180
|
spellings[[rule, attr]] << grouped[spelling.to_s].to_a
|
|
178
181
|
when :nested
|
|
179
182
|
child_type = attr.type(register)
|
|
@@ -193,7 +196,7 @@ module Lutaml
|
|
|
193
196
|
attr.collection? ? items : items.first)
|
|
194
197
|
end
|
|
195
198
|
end
|
|
196
|
-
unless spellings.empty?
|
|
199
|
+
unless !spellings || spellings.empty?
|
|
197
200
|
spellings.each do |(rule, attr), groups|
|
|
198
201
|
# Interpretive order for shared-attribute groups is
|
|
199
202
|
# spelling-group order (first spelling's matches, then
|
|
@@ -397,8 +400,8 @@ module Lutaml
|
|
|
397
400
|
|
|
398
401
|
def group_children(value, row_tags = nil)
|
|
399
402
|
grouped = {}
|
|
400
|
-
tagged = {}
|
|
401
403
|
want_tags = !row_tags.nil?
|
|
404
|
+
tagged = want_tags ? {} : nil
|
|
402
405
|
value.count.times do |i|
|
|
403
406
|
child = value.at(i)
|
|
404
407
|
# One FFI crossing per child: the name was read twice here
|