lutaml-model 0.8.149 → 0.8.150
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/model/serialize/initialization.rb +22 -4
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/mapping.rb +12 -1
- 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: d607b4c544596f3b22830d7d5636a86415609ba1589e6749ce22f6d5ed7bc800
|
|
4
|
+
data.tar.gz: 9eb79acc5964cab4c5c1930c30579c2fd7cb5c5e29720d131208d4ce74667e24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04e478685e1c6c4a30a9475ba31b39fc2353858f8929c7725101da530648628c58985c0e086f664a06c75fc117fd521b7ad6e63b547d5bbdc571eb8113810275
|
|
7
|
+
data.tar.gz: f3dee9b947b17ea7aceda5c4178a89aeb2d88c43a0007fb56adadee103e1f9c2b6ce6cf5139870fb42bdc218eb1b9bd4c92750c54bbab4cd0e94549169f554f0
|
|
@@ -613,11 +613,12 @@ module Lutaml
|
|
|
613
613
|
register_id = instance.lutaml_register
|
|
614
614
|
attrs_by = attributes(register_id)
|
|
615
615
|
writers = instantiate_writers(register_id)
|
|
616
|
+
raw_readers = instantiate_raw_readers(register_id)
|
|
616
617
|
given = 0
|
|
617
618
|
# Memoized pair array: Hash#each mints a [name, attr] pair
|
|
618
619
|
# per attribute per instance (~5 allocs/instance on
|
|
619
620
|
# hydration-heavy corpora); Array#each reuses its elements.
|
|
620
|
-
instantiate_attr_pairs(register_id).each do |name, attr|
|
|
621
|
+
instantiate_attr_pairs(register_id).each do |name, attr, str_name|
|
|
621
622
|
next if attr.derived?
|
|
622
623
|
|
|
623
624
|
# Symbol keys hit directly (native-extension callers);
|
|
@@ -625,7 +626,7 @@ module Lutaml
|
|
|
625
626
|
key = if attrs.key?(name)
|
|
626
627
|
given += 1
|
|
627
628
|
name
|
|
628
|
-
elsif
|
|
629
|
+
elsif attrs.key?(str_name)
|
|
629
630
|
given += 1
|
|
630
631
|
str_name
|
|
631
632
|
end
|
|
@@ -647,7 +648,7 @@ module Lutaml
|
|
|
647
648
|
# only then is the default seeded. The writer's own
|
|
648
649
|
# value_set_for (inside the compiled writer) already
|
|
649
650
|
# marked it set, so it renders.
|
|
650
|
-
raw = instance.public_send(
|
|
651
|
+
raw = instance.public_send(raw_readers[name])
|
|
651
652
|
unset = raw.nil? ||
|
|
652
653
|
raw.equal?(Lutaml::Model::UninitializedClass.instance) ||
|
|
653
654
|
raw.equal?(Lutaml::Model::Serialize::LAZY_EMPTY_COLLECTION)
|
|
@@ -688,7 +689,24 @@ module Lutaml
|
|
|
688
689
|
# pair array disappears (see the instantiate comment).
|
|
689
690
|
def instantiate_attr_pairs(register_id = nil)
|
|
690
691
|
(@instantiate_attr_pairs ||= {})[register_id] ||=
|
|
691
|
-
attributes(register_id).
|
|
692
|
+
attributes(register_id).map do |name, attr|
|
|
693
|
+
# The string name is precomputed beside the symbol: the
|
|
694
|
+
# absent-key fallback (string-keyed callers, from_hash)
|
|
695
|
+
# would otherwise mint `name.to_s` per attribute per
|
|
696
|
+
# instance — one fresh string per absent attribute.
|
|
697
|
+
[name, attr, name.to_s]
|
|
698
|
+
end.freeze
|
|
699
|
+
end
|
|
700
|
+
|
|
701
|
+
# Raw-state reader names, precomputed once per (class, register):
|
|
702
|
+
# instantiating interpolates the reader symbol per absent
|
|
703
|
+
# attribute per instance otherwise — a fresh string + symbol
|
|
704
|
+
# lookup for state that is identical for every instance.
|
|
705
|
+
def instantiate_raw_readers(register_id = nil)
|
|
706
|
+
(@instantiate_raw_readers ||= {})[register_id] ||=
|
|
707
|
+
attributes(register_id).to_h do |name, _|
|
|
708
|
+
[name, :"__lutaml_raw_#{name}"]
|
|
709
|
+
end.freeze
|
|
692
710
|
end
|
|
693
711
|
|
|
694
712
|
# Define register-specific attribute methods on the class itself.
|
data/lib/lutaml/model/version.rb
CHANGED
data/lib/lutaml/xml/mapping.rb
CHANGED
|
@@ -1460,11 +1460,22 @@ module Lutaml
|
|
|
1460
1460
|
# Raw xsi:schemaLocation capture must stay out of the way, or the
|
|
1461
1461
|
# writer re-emits the value beside the mapped attribute (#1042).
|
|
1462
1462
|
def schema_location_mapped?(register_id = nil)
|
|
1463
|
-
|
|
1463
|
+
# Memoized per register against the mapping's rule-records
|
|
1464
|
+
# version: the walk re-asks per parse, and the un-memoized form
|
|
1465
|
+
# allocated a merged attributes hash plus a name string per rule
|
|
1466
|
+
# per ask.
|
|
1467
|
+
version = rule_records_version.to_i
|
|
1468
|
+
cache = (@schema_location_mapped ||= {})
|
|
1469
|
+
cached = cache[register_id]
|
|
1470
|
+
return cached[:value] if cached && cached[:version] == version
|
|
1471
|
+
|
|
1472
|
+
value = mapping_attributes_hash(register_id).each_value.any? do |rule_or_array|
|
|
1464
1473
|
Array(rule_or_array).any? do |rule|
|
|
1465
1474
|
rule.name.to_s == "schemaLocation"
|
|
1466
1475
|
end
|
|
1467
1476
|
end
|
|
1477
|
+
cache[register_id] = { version: version, value: value }
|
|
1478
|
+
value
|
|
1468
1479
|
end
|
|
1469
1480
|
|
|
1470
1481
|
# Raw hash access for inheritance and deep_dup operations.
|