lutaml-model 0.8.147 → 0.8.148
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: a830ec6a143525a0d59b70b642ffa232553eb7aadb9d1b6a7cd740a1cfcad6cb
|
|
4
|
+
data.tar.gz: 565167c64a78c785ff6f6742bce3ee5c56083022bd9c37746af983cace306262
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e26f1bec70e96e4311140e345cd7cb15e048b71fe37df05d96bbe8cf319b959bba4e6a6073ac61767e4a6c8a94c7a3e14c5decab75412718bb73cf7d7fee6e1a
|
|
7
|
+
data.tar.gz: a2c55f36c898966db5499b0485702a50749bef098ff3f07e8e4ee90caab1d2c112294adc59da7a6dac486d256679f4f27a426b8384e35932a3228998b27e21f5
|
|
@@ -560,8 +560,14 @@ module Lutaml
|
|
|
560
560
|
# constructor contract — internal state the compiled seeding
|
|
561
561
|
# cannot know about — so they construct through the real
|
|
562
562
|
# constructor, then carry the parse's register context.
|
|
563
|
+
# Attribute state then goes back to the deserialization
|
|
564
|
+
# markers: the parse reads them to tell an absent element from
|
|
565
|
+
# a value a writer assigned (#922), so constructor-seeded
|
|
566
|
+
# defaults would otherwise count as set and a render_default:
|
|
567
|
+
# false element would be written back out.
|
|
563
568
|
if constructs_through_initialize?
|
|
564
569
|
instance = new(lutaml_register: register_id)
|
|
570
|
+
instance.init_deserialization_state(register_id)
|
|
565
571
|
return instance
|
|
566
572
|
end
|
|
567
573
|
instance = allocate
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# from_xml builds a custom-initialize class through its constructor so the
|
|
6
|
+
# class's own internal state exists. Its attributes must still come out of
|
|
7
|
+
# the parse exactly as they do for the same class on the standard
|
|
8
|
+
# initializer: constructor-seeded defaults are not values the document
|
|
9
|
+
# set, so an absent render_default: false element stays absent.
|
|
10
|
+
RSpec.describe "XML deserialization of a custom-initialize class" do
|
|
11
|
+
let(:standard) do
|
|
12
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
13
|
+
attribute :name, :string
|
|
14
|
+
attribute :bidi, :boolean, default: -> { false }
|
|
15
|
+
|
|
16
|
+
xml do
|
|
17
|
+
element "para"
|
|
18
|
+
map_element "name", to: :name
|
|
19
|
+
map_element "bidi", to: :bidi
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:custom) do
|
|
25
|
+
Class.new(standard) do
|
|
26
|
+
def initialize(*args, **kwargs)
|
|
27
|
+
@internal = :ready
|
|
28
|
+
super
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
attr_reader :internal
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
stub_const("XmlConstructorDefaultsStandard", standard)
|
|
37
|
+
stub_const("XmlConstructorDefaultsCustom", custom)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "runs the class's own initialize" do
|
|
41
|
+
expect(custom.from_xml("<para><name>a</name></para>").internal).to eq(:ready)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "keeps an absent defaulted element absent on round trip" do
|
|
45
|
+
xml = custom.from_xml("<para><name>a</name></para>").to_xml
|
|
46
|
+
|
|
47
|
+
expect(xml).not_to include("bidi")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
[
|
|
51
|
+
"<para><name>a</name></para>",
|
|
52
|
+
"<para><name>a</name><bidi>true</bidi></para>",
|
|
53
|
+
"<para><name>a</name><bidi>false</bidi></para>",
|
|
54
|
+
].each do |input|
|
|
55
|
+
it "parses #{input} the same as the standard initializer" do
|
|
56
|
+
expected = standard.from_xml(input)
|
|
57
|
+
actual = custom.from_xml(input)
|
|
58
|
+
|
|
59
|
+
expect([actual.bidi, actual.to_xml])
|
|
60
|
+
.to eq([expected.bidi, expected.to_xml])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
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.148
|
|
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-10-
|
|
11
|
+
date: 2026-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -1918,6 +1918,7 @@ files:
|
|
|
1918
1918
|
- spec/lutaml/model/walk_constructor_spec.rb
|
|
1919
1919
|
- spec/lutaml/model/with_child_mapping_spec.rb
|
|
1920
1920
|
- spec/lutaml/model/writer_assigned_attribute_spec.rb
|
|
1921
|
+
- spec/lutaml/model/xml_constructor_defaults_spec.rb
|
|
1921
1922
|
- spec/lutaml/model/xml_decoupling_spec.rb
|
|
1922
1923
|
- spec/lutaml/model/xsd_form_default_patterns_spec.rb
|
|
1923
1924
|
- spec/lutaml/model/xsd_patterns_spec.rb
|