lutaml-model 0.3.22 → 0.3.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d740eaaa52ff7479fc3e0f23aa3fb308bd8b61f820ac22f036b31f24d696989
4
- data.tar.gz: '0294c66616f39e84e931b626f776ee555450ac962018bf3189200467761e2707'
3
+ metadata.gz: e7e401ce23a01b4dc80f709b71326b598cb9b9024b81d2a94f501bebf8112a14
4
+ data.tar.gz: 30534172ee835a9170e4335029702ec87ec4225c52e9e09566cb694fbd9c258d
5
5
  SHA512:
6
- metadata.gz: 56675b27dfbf1fa77986f5793f48dd8f5b53b69d5fa989209f79c1f2827ee0ed46eeeeecaed72904be2053a12c4653dab5d06dd0b1401754a06e9a0a9db8fc0f
7
- data.tar.gz: cedbee96c00a6d43065df43acc8ee7d5262bd03265fda81fc85698c1abb7c00f0989c7cc9d1afe1f5038b4323e886adadd0609250dd9f952e2e1b33fcc9b7fee
6
+ metadata.gz: ce9d2be7aac031cba94181053fa59f19cb61ed6fafbdda177bec369a03fd92d53dcfc9caf43a34ebb439c7d69d2bf3f0db1a56a49e5cc34021a8fe4a0fc7fe25
7
+ data.tar.gz: 187168f579188ad1458013375fd5bacb6718dbb29d77994229c1c11fb14bcec5df8bae8bcfbe42dc3e57a5918c663741df7168338a2df36869562613aa06d149
@@ -200,11 +200,10 @@ module Lutaml
200
200
 
201
201
  def cast(value, format, options = {})
202
202
  value ||= [] if collection?
203
- instance = options[:instance]
204
203
 
205
204
  if value.is_a?(Array)
206
205
  value.map do |v|
207
- cast(v, format, instance: instance)
206
+ cast(v, format, options)
208
207
  end
209
208
  elsif type <= Serialize && value.is_a?(Hash)
210
209
  type.apply_mappings(value, format, options)
@@ -35,7 +35,7 @@ module Lutaml
35
35
  subclass.instance_variable_set(:@attributes,
36
36
  Utils.deep_dup(@attributes))
37
37
  subclass.instance_variable_set(:@mappings, Utils.deep_dup(@mappings))
38
- subclass.instance_variable_set(:@model, subclass)
38
+ subclass.instance_variable_set(:@model, @model || subclass)
39
39
  end
40
40
 
41
41
  def model(klass = nil)
@@ -310,6 +310,7 @@ module Lutaml
310
310
  def apply_xml_mapping(doc, instance, options = {})
311
311
  return instance unless doc
312
312
 
313
+ options[:default_namespace] = mappings_for(:xml)&.namespace_uri if options[:default_namespace].nil?
313
314
  mappings = mappings_for(:xml).mappings
314
315
 
315
316
  if doc.is_a?(Array)
@@ -340,14 +341,14 @@ module Lutaml
340
341
  doc.node.inner_xml
341
342
  elsif rule.content_mapping?
342
343
  doc["text"]
343
- elsif doc.key_exist?(rule.namespaced_name)
344
- doc.fetch(rule.namespaced_name)
344
+ elsif doc.key_exist?(rule.namespaced_name(options[:default_namespace]))
345
+ doc.fetch(rule.namespaced_name(options[:default_namespace]))
345
346
  else
346
347
  defaults_used << rule.to
347
348
  rule.to_value_for(instance)
348
349
  end
349
350
 
350
- value = normalize_xml_value(value, rule)
351
+ value = normalize_xml_value(value, rule, options)
351
352
  rule.deserialize(instance, value, attributes, self)
352
353
  end
353
354
 
@@ -388,7 +389,7 @@ module Lutaml
388
389
  instance
389
390
  end
390
391
 
391
- def normalize_xml_value(value, rule)
392
+ def normalize_xml_value(value, rule, options = {})
392
393
  attr = attribute_for_rule(rule)
393
394
 
394
395
  value = [value].compact if attr&.collection? && !value.is_a?(Array)
@@ -405,11 +406,11 @@ module Lutaml
405
406
 
406
407
  return value unless cast_value?(attr, rule)
407
408
 
409
+ options.merge(caller_class: self, mixed_content: rule.mixed_content)
408
410
  attr.cast(
409
411
  value,
410
412
  :xml,
411
- caller_class: self,
412
- mixed_content: rule.mixed_content,
413
+ options,
413
414
  )
414
415
  end
415
416
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.3.22"
5
+ VERSION = "0.3.23"
6
6
  end
7
7
  end
@@ -73,7 +73,7 @@ module Lutaml
73
73
  end
74
74
  end
75
75
 
76
- def namespaced_name
76
+ def namespaced_name(parent_namespace = nil)
77
77
  if name == "lang"
78
78
  "#{prefix}:#{name}"
79
79
  elsif namespace_set? || @attribute
@@ -81,7 +81,7 @@ module Lutaml
81
81
  elsif default_namespace
82
82
  "#{default_namespace}:#{name}"
83
83
  else
84
- name
84
+ [parent_namespace, name].compact.join(":")
85
85
  end
86
86
  end
87
87
 
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.3.22
4
+ version: 0.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.