lutaml-model 0.8.144 → 0.8.145

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: ff4c24c792fe315c6798bf64b67dbc4924fc919fc447e4a0264467d169a80315
4
- data.tar.gz: 15621c39ad1d06dddbca3c9b0ef809b1a87d13222ef850c0cdb557da3317ca1d
3
+ metadata.gz: 1d4a991baea8734712513f2d1ffb0025d0a5867f174a40b32bee58b1be5017c5
4
+ data.tar.gz: f1713d5b0ef5024da66ee23f8251604da86fd3f8d7035e7f64118bf080ea9128
5
5
  SHA512:
6
- metadata.gz: 21de2545ba67ce8357cd0216e70a085648ea24153cff022a805005b677d7d90ab51af50869cfc6335d6aad5404f4bb4fde30ed9f6389a31ff9b7ac51580646b4
7
- data.tar.gz: d46faf8a708c88622abb2d560bf2f533da86815553c81049b8d432f71d60cfad67a65e567858454a7ecad721b2d2e02c2c3d6bd8bc173416903dc5d4faab7065
6
+ metadata.gz: db827973c88ea9fe1779a0105d18ef1d0f93868fa4a59147a029c504005ec5f5e50378a7f90c490097e24d20c62fb33531a8fe277fb7620ed3cd17debdd2adaf
7
+ data.tar.gz: 90045bda2ce6c2605ca3708527c44ad7811cacb6cb8d4f72d83f3a875a3a043a84503dc48f24f716d94f5e92e367d6a4bfb2fa556982d14db65125623d885252
@@ -67,6 +67,21 @@ module Lutaml
67
67
  klass = Object.const_get(klass_name)
68
68
 
69
69
  propagated = options.slice(*Lutaml::Model::Attribute::CHILD_PROPAGATION_KEYS)
70
+
71
+ # A map entry that resolves to the deserializing class itself
72
+ # (a subclass inheriting its base's map, or an apply_mappings
73
+ # override delegating back to super for its own concrete class)
74
+ # must fall through to this class's real deserialization:
75
+ # re-dispatching apply_mappings would resolve the same entry
76
+ # again and never make progress.
77
+ if klass == model
78
+ transformer = Lutaml::Model::Config.transformer_for(format)
79
+ return transformer.data_to_model(
80
+ self, doc, format,
81
+ propagated.merge(register: instance.lutaml_register)
82
+ )
83
+ end
84
+
70
85
  klass.apply_mappings(doc, format,
71
86
  propagated.merge(register: instance.lutaml_register))
72
87
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.144"
5
+ VERSION = "0.8.145"
6
6
  end
7
7
  end
@@ -125,6 +125,21 @@ module PolymorphicSpec
125
125
  }
126
126
  end
127
127
  end
128
+
129
+ # A polymorphic map whose entry resolves to the class carrying it
130
+ # (e.g. a subclass inheriting its base's map, or an apply_mappings
131
+ # override delegating back to super for its own concrete class).
132
+ class SelfResolving < Lutaml::Model::Serializable
133
+ attribute :_type, :string
134
+ attribute :name, :string
135
+
136
+ key_value do
137
+ map "_type", to: :_type, polymorphic_map: {
138
+ "self_resolving" => "PolymorphicSpec::Base::SelfResolving",
139
+ }
140
+ map "name", to: :name
141
+ end
142
+ end
128
143
  end
129
144
 
130
145
  module Child
@@ -546,4 +561,17 @@ RSpec.describe "Polymorphic" do
546
561
  end
547
562
  end
548
563
  end
564
+
565
+ # A polymorphic map that resolves a document to the very class that is
566
+ # deserializing it must fall through to the model's own
567
+ # deserialization, not re-dispatch apply_mappings forever.
568
+ context "when the polymorphic map resolves to the deserializing class" do
569
+ it "deserializes without recursing" do
570
+ model = PolymorphicSpec::Base::SelfResolving.apply_mappings(
571
+ { "_type" => "self_resolving", "name" => "x" }, :hash
572
+ )
573
+ expect(model).to be_a(PolymorphicSpec::Base::SelfResolving)
574
+ expect(model.name).to eq("x")
575
+ end
576
+ end
549
577
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.144
4
+ version: 0.8.145
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.