lutaml-model 0.8.9 → 0.8.11

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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-repos.json +1 -0
  3. data/.rubocop_todo.yml +52 -22
  4. data/README.adoc +43 -0
  5. data/docs/_guides/jsonld-serialization.adoc +3 -1
  6. data/docs/_guides/rdf-serialization.adoc +94 -8
  7. data/docs/_guides/turtle-serialization.adoc +17 -4
  8. data/lib/lutaml/jsonld/transform.rb +70 -24
  9. data/lib/lutaml/key_value/transform.rb +5 -5
  10. data/lib/lutaml/key_value/transformation/collection_serializer.rb +25 -11
  11. data/lib/lutaml/key_value/transformation/value_serializer.rb +7 -7
  12. data/lib/lutaml/key_value/transformation.rb +27 -17
  13. data/lib/lutaml/model/adapter_resolver.rb +4 -6
  14. data/lib/lutaml/model/attribute.rb +26 -23
  15. data/lib/lutaml/model/cached_type_resolver.rb +10 -9
  16. data/lib/lutaml/model/cli.rb +1 -1
  17. data/lib/lutaml/model/collection.rb +4 -4
  18. data/lib/lutaml/model/comparable_model.rb +11 -11
  19. data/lib/lutaml/model/config.rb +1 -1
  20. data/lib/lutaml/model/consolidation/dispatcher.rb +1 -1
  21. data/lib/lutaml/model/consolidation/pattern_chunker.rb +3 -3
  22. data/lib/lutaml/model/format_registry.rb +6 -4
  23. data/lib/lutaml/model/global_context.rb +2 -2
  24. data/lib/lutaml/model/global_register.rb +1 -1
  25. data/lib/lutaml/model/instrumentation.rb +1 -1
  26. data/lib/lutaml/model/mapping/mapping_rule.rb +3 -3
  27. data/lib/lutaml/model/mapping/model_mapping.rb +1 -1
  28. data/lib/lutaml/model/mapping/model_mapping_rule.rb +1 -1
  29. data/lib/lutaml/model/register.rb +3 -3
  30. data/lib/lutaml/model/render_policy.rb +11 -17
  31. data/lib/lutaml/model/runtime_compatibility.rb +0 -1
  32. data/lib/lutaml/model/schema/xml_compiler/group.rb +1 -1
  33. data/lib/lutaml/model/schema/xml_compiler/registry_generator.rb +1 -1
  34. data/lib/lutaml/model/schema/xml_compiler/sequence.rb +0 -2
  35. data/lib/lutaml/model/schema/xml_compiler.rb +14 -14
  36. data/lib/lutaml/model/serialize/attribute_definition.rb +1 -1
  37. data/lib/lutaml/model/serialize/deserialization_context.rb +50 -0
  38. data/lib/lutaml/model/serialize/format_conversion.rb +2 -2
  39. data/lib/lutaml/model/serialize/initialization.rb +44 -7
  40. data/lib/lutaml/model/serialize/model_import.rb +1 -1
  41. data/lib/lutaml/model/serialize.rb +8 -1
  42. data/lib/lutaml/model/services/rule_value_extractor.rb +2 -1
  43. data/lib/lutaml/model/store.rb +77 -24
  44. data/lib/lutaml/model/transformation_registry.rb +1 -1
  45. data/lib/lutaml/model/type_context.rb +7 -1
  46. data/lib/lutaml/model/type_resolver.rb +1 -6
  47. data/lib/lutaml/model/utils.rb +19 -6
  48. data/lib/lutaml/model/validation_framework.rb +1 -1
  49. data/lib/lutaml/model/value_transformer.rb +2 -2
  50. data/lib/lutaml/model/version.rb +1 -1
  51. data/lib/lutaml/rdf/mapping.rb +19 -13
  52. data/lib/lutaml/rdf/mapping_rule.rb +19 -2
  53. data/lib/lutaml/rdf/member_rule.rb +19 -2
  54. data/lib/lutaml/rdf/transform.rb +20 -11
  55. data/lib/lutaml/turtle/transform.rb +125 -53
  56. data/lib/lutaml/xml/adapter/adapter_helpers.rb +1 -1
  57. data/lib/lutaml/xml/adapter/base_adapter.rb +10 -14
  58. data/lib/lutaml/xml/adapter/namespace_uri_collector.rb +3 -3
  59. data/lib/lutaml/xml/adapter/plan_based_builder.rb +14 -14
  60. data/lib/lutaml/xml/adapter/xml_serializer.rb +3 -3
  61. data/lib/lutaml/xml/configurable.rb +2 -1
  62. data/lib/lutaml/xml/data_model.rb +2 -2
  63. data/lib/lutaml/xml/decisions/decision_context.rb +3 -3
  64. data/lib/lutaml/xml/decisions/rules/element_form_default_unqualified_rule.rb +1 -1
  65. data/lib/lutaml/xml/decisions/rules/element_form_option_rule.rb +1 -1
  66. data/lib/lutaml/xml/decisions/rules/used_prefix_rule.rb +1 -1
  67. data/lib/lutaml/xml/declaration_plan.rb +2 -2
  68. data/lib/lutaml/xml/declaration_planner.rb +12 -13
  69. data/lib/lutaml/xml/document.rb +13 -13
  70. data/lib/lutaml/xml/format_chooser.rb +3 -3
  71. data/lib/lutaml/xml/hoisting_algorithm.rb +1 -1
  72. data/lib/lutaml/xml/mapping.rb +2 -2
  73. data/lib/lutaml/xml/mapping_rule.rb +16 -3
  74. data/lib/lutaml/xml/model_transform.rb +17 -19
  75. data/lib/lutaml/xml/namespace_collector.rb +10 -10
  76. data/lib/lutaml/xml/namespace_declaration.rb +2 -2
  77. data/lib/lutaml/xml/namespace_declaration_data.rb +5 -8
  78. data/lib/lutaml/xml/namespace_scope_config.rb +3 -2
  79. data/lib/lutaml/xml/namespace_type_resolver.rb +4 -4
  80. data/lib/lutaml/xml/nokogiri/element.rb +2 -2
  81. data/lib/lutaml/xml/polymorphic_value_handler.rb +1 -1
  82. data/lib/lutaml/xml/schema/xsd/base.rb +7 -7
  83. data/lib/lutaml/xml/schema/xsd/choice.rb +2 -2
  84. data/lib/lutaml/xml/schema/xsd/complex_type.rb +5 -5
  85. data/lib/lutaml/xml/schema/xsd/errors/message_builder.rb +3 -3
  86. data/lib/lutaml/xml/schema/xsd/group.rb +2 -2
  87. data/lib/lutaml/xml/schema/xsd/sequence.rb +2 -2
  88. data/lib/lutaml/xml/schema/xsd_schema.rb +5 -5
  89. data/lib/lutaml/xml/serialization/format_conversion.rb +4 -3
  90. data/lib/lutaml/xml/transformation/element_builder.rb +4 -2
  91. data/lib/lutaml/xml/transformation/rule_applier.rb +2 -2
  92. data/lib/lutaml/xml/transformation/value_serializer.rb +4 -6
  93. data/lib/lutaml/xml/transformation.rb +4 -4
  94. data/lib/lutaml/xml/type/configurable.rb +0 -4
  95. data/lib/lutaml/xml/xml_element.rb +21 -13
  96. data/lutaml-model.gemspec +1 -1
  97. data/spec/lutaml/jsonld/transform_spec.rb +239 -0
  98. data/spec/lutaml/model/cached_type_resolver_spec.rb +3 -3
  99. data/spec/lutaml/model/optimization_spec.rb +228 -0
  100. data/spec/lutaml/model/store_spec.rb +195 -0
  101. data/spec/lutaml/rdf/mapping_rule_spec.rb +97 -0
  102. data/spec/lutaml/rdf/mapping_spec.rb +74 -4
  103. data/spec/lutaml/rdf/member_rule_spec.rb +41 -0
  104. data/spec/lutaml/rdf/rdf_transform_spec.rb +95 -29
  105. data/spec/lutaml/turtle/mapping_spec.rb +2 -2
  106. data/spec/lutaml/turtle/transform_spec.rb +315 -0
  107. data/spec/lutaml/xml/data_model_spec.rb +10 -28
  108. metadata +7 -4
@@ -5,9 +5,15 @@ require "weakref"
5
5
  module Lutaml
6
6
  module Model
7
7
  class Store
8
- # Compact dead WeakRef shells after this many entries per class bucket.
8
+ # Compact dead WeakRef shells once a class bucket grows past this size.
9
9
  COMPACTION_THRESHOLD = 1000
10
10
 
11
+ # Once the threshold is exceeded, only compact every Nth subsequent
12
+ # register call. Amortises the O(N) reject! over N inserts so
13
+ # register stays O(1) per call rather than O(N) per call (O(N^2)
14
+ # cumulatively for the class).
15
+ COMPACTION_INTERVAL = 1000
16
+
11
17
  class << self
12
18
  def instance
13
19
  @instance ||= new
@@ -36,45 +42,46 @@ module Lutaml
36
42
 
37
43
  def initialize
38
44
  @store = ::Hash.new { |hash, key| hash[key] = [] }
39
- # Lazy index: built on first resolve for a given (class, key) pair.
40
- # Key: [class_name, reference_method] { value => WeakRef(object) }
45
+ # Nested index: { model_key => { reference_key => { value => WeakRef(object) } } }
46
+ # Grouped by model_key so register only iterates this class's own indices.
41
47
  @index = {}
48
+ @inserts_since_compaction = ::Hash.new(0)
49
+ @compaction_count = 0
42
50
  end
43
51
 
44
52
  def register(object)
45
53
  model_key = object.class.to_s
46
54
  refs = @store[model_key]
47
55
  refs << WeakRef.new(object)
56
+ @inserts_since_compaction[model_key] += 1
48
57
 
49
- compact_if_needed(refs)
58
+ compact_if_needed(refs, model_key)
50
59
 
51
60
  update_existing_indices(object, model_key)
52
61
  end
53
62
 
54
63
  def resolve(model_class, reference_key, reference_value)
55
64
  model_key = model_class.to_s
56
- index_key = [model_key, reference_key]
65
+ model_indices = @index[model_key]
57
66
 
58
- # Build index lazily on first resolve for this (class, key) pair
59
- unless @index.key?(index_key)
60
- ensure_index(index_key, model_key,
61
- reference_key)
67
+ unless model_indices&.key?(reference_key)
68
+ model_indices = ensure_model_index(model_key)
69
+ build_index(model_indices, model_key, reference_key)
62
70
  end
63
71
 
64
- # O(1) indexed lookup
65
- entry = @index[index_key][reference_value]
72
+ entry = model_indices[reference_key][reference_value]
66
73
  return nil unless entry
67
74
 
68
- begin
69
- entry.__getobj__ if entry.weakref_alive?
70
- rescue WeakRef::RefError
71
- nil
72
- end
75
+ obj = dereference(entry)
76
+ model_indices[reference_key].delete(reference_value) unless obj
77
+ obj
73
78
  end
74
79
 
75
80
  def clear
76
81
  @store = ::Hash.new { |hash, key| hash[key] = [] }
77
82
  @index = {}
83
+ @inserts_since_compaction = ::Hash.new(0)
84
+ @compaction_count = 0
78
85
  end
79
86
 
80
87
  def store
@@ -87,11 +94,31 @@ module Lutaml
87
94
  end
88
95
  end
89
96
 
97
+ def refs_for(model_key)
98
+ @store[model_key]
99
+ end
100
+
101
+ def inserts_since_compaction
102
+ @inserts_since_compaction
103
+ end
104
+
105
+ def compaction_count
106
+ @compaction_count
107
+ end
108
+
109
+ def index_entry_count(model_key)
110
+ @index[model_key]&.sum { |_reference_key, entries| entries.size } || 0
111
+ end
112
+
90
113
  private
91
114
 
115
+ def ensure_model_index(model_key)
116
+ @index[model_key] ||= {}
117
+ end
118
+
92
119
  # Build index for a (model_class, reference_key) pair by scanning existing instances.
93
- def ensure_index(index_key, model_key, reference_key)
94
- entries = @index[index_key] = {}
120
+ def build_index(model_indices, model_key, reference_key)
121
+ entries = model_indices[reference_key] = {}
95
122
  @store[model_key]&.each do |ref|
96
123
  obj = ref.__getobj__
97
124
  value = obj.public_send(reference_key)
@@ -101,27 +128,53 @@ module Lutaml
101
128
  end
102
129
  end
103
130
 
104
- # Update indices that already exist for this model class.
131
+ # Update indices that already exist for this model class only.
132
+ # O(K) where K = number of reference keys indexed for this class,
133
+ # not O(N×K) across all classes.
105
134
  def update_existing_indices(object, model_key)
106
- @index.each do |index_key, entries|
107
- next unless index_key[0] == model_key
135
+ model_indices = @index[model_key]
136
+ return unless model_indices
108
137
 
109
- key_method = index_key[1]
110
- value = object.public_send(key_method)
138
+ model_indices.each do |reference_key, entries|
139
+ value = object.public_send(reference_key)
111
140
  entries[value] = WeakRef.new(object) if value
112
141
  rescue WeakRef::RefError
113
142
  next
114
143
  end
115
144
  end
116
145
 
117
- def compact_if_needed(refs)
146
+ def dereference(entry)
147
+ entry.__getobj__ if entry.weakref_alive?
148
+ rescue WeakRef::RefError
149
+ nil
150
+ end
151
+
152
+ def compact_if_needed(refs, model_key)
118
153
  return unless refs.size > COMPACTION_THRESHOLD
154
+ return unless @inserts_since_compaction[model_key] >= COMPACTION_INTERVAL
119
155
 
156
+ @inserts_since_compaction[model_key] = 0
157
+ @compaction_count += 1
120
158
  refs.reject! do |ref|
121
159
  !ref.weakref_alive?
122
160
  rescue WeakRef::RefError
123
161
  true
124
162
  end
163
+ prune_index(model_key)
164
+ end
165
+
166
+ def prune_index(model_key)
167
+ model_indices = @index[model_key]
168
+ return unless model_indices
169
+
170
+ model_indices.delete_if do |_reference_key, entries|
171
+ entries.delete_if do |_value, ref|
172
+ !ref.weakref_alive?
173
+ rescue WeakRef::RefError
174
+ true
175
+ end
176
+ entries.empty?
177
+ end
125
178
  end
126
179
  end
127
180
  end
@@ -185,7 +185,7 @@ module Lutaml
185
185
  # Build mapping OUTSIDE any lock to avoid deadlock
186
186
  # (ensure_mappings_imported! may recursively call get_or_build_mapping)
187
187
  mapping = model_class.mappings[format]
188
- mapping = mapping || model_class.send(:default_mappings, format)
188
+ mapping = mapping || model_class.default_mappings(format)
189
189
 
190
190
  mapping.ensure_mappings_imported!(register_id)
191
191
 
@@ -47,6 +47,9 @@ module Lutaml
47
47
  # @return [Array<TypeSubstitution>] Type substitution rules
48
48
  attr_reader :substitutions
49
49
 
50
+ # @return [Hash{Class => Class}] Pre-built Hash for O(1) substitution lookup
51
+ attr_reader :substitution_hash
52
+
50
53
  # @return [Array<TypeContext>] Fallback contexts (in order)
51
54
  attr_reader :fallback_contexts
52
55
 
@@ -60,6 +63,9 @@ module Lutaml
60
63
  @id = id.to_sym
61
64
  @registry = registry
62
65
  @substitutions = Array(substitutions).freeze
66
+ @substitution_hash = @substitutions.to_h do |s|
67
+ [s.from_type, s.to_type]
68
+ end.freeze
63
69
  @fallback_contexts = Array(fallback_contexts).freeze
64
70
  freeze
65
71
  end
@@ -254,7 +260,7 @@ module Lutaml
254
260
  ctx
255
261
  when Symbol, String
256
262
  # Try to look up from GlobalContext if available
257
- if defined?(GlobalContext) && GlobalContext.respond_to?(:registry)
263
+ if defined?(GlobalContext)
258
264
  GlobalContext.registry.lookup(ctx)
259
265
  end
260
266
  end
@@ -157,12 +157,7 @@ module Lutaml
157
157
  def self.apply_substitutions(type, context)
158
158
  return type if context.nil? || context.substitutions.empty?
159
159
 
160
- context.substitutions.each do |sub|
161
- substituted = sub.apply(type)
162
- return substituted if substituted
163
- end
164
-
165
- type
160
+ context.substitution_hash[type] || type
166
161
  end
167
162
 
168
163
  # Get all available type names from context and fallbacks.
@@ -163,12 +163,25 @@ module Lutaml
163
163
  # fetch_str_or_sym(hash, :key) # => "value"
164
164
  # fetch_str_or_sym(hash, "invalid_key") # => nil
165
165
  def fetch_str_or_sym(hash, key, default = nil)
166
- if hash.key?(key.to_s)
167
- hash[key.to_s]
168
- elsif hash.key?(key.to_sym)
169
- hash[key.to_sym]
166
+ case key
167
+ when String
168
+ if hash.key?(key)
169
+ hash[key]
170
+ else
171
+ (hash.key?(key.to_sym) ? hash[key.to_sym] : default)
172
+ end
173
+ when Symbol
174
+ if hash.key?(key)
175
+ hash[key]
176
+ else
177
+ (hash.key?(key.to_s) ? hash[key.to_s] : default)
178
+ end
170
179
  else
171
- default
180
+ if hash.key?(key.to_s)
181
+ hash[key.to_s]
182
+ else
183
+ (hash.key?(key.to_sym) ? hash[key.to_sym] : default)
184
+ end
172
185
  end
173
186
  end
174
187
 
@@ -183,7 +196,7 @@ module Lutaml
183
196
  end
184
197
 
185
198
  def add_singleton_method_if_not_defined(instance, method_name, &)
186
- return if instance.respond_to?(method_name)
199
+ return if instance.singleton_class.method_defined?(method_name, false)
187
200
 
188
201
  instance.define_singleton_method(method_name, &)
189
202
  end
@@ -38,7 +38,7 @@ module Lutaml
38
38
  next unless rule.applicable?(context)
39
39
 
40
40
  issues = rule.check(context)
41
- if context.respond_to?(:add_error)
41
+ if context.is_a?(Validation::Context)
42
42
  issues.each { |i| context.add_error(i) }
43
43
  end
44
44
  all_issues.concat(issues)
@@ -10,11 +10,11 @@ module Lutaml
10
10
  end
11
11
 
12
12
  def self.from(value, format)
13
- new.send(:"from_#{format}", value)
13
+ new.public_send(:"from_#{format}", value)
14
14
  end
15
15
 
16
16
  def self.to(value, format)
17
- new(value).send(:"to_#{format}")
17
+ new(value).public_send(:"to_#{format}")
18
18
  end
19
19
 
20
20
  def self.can_transform?(method, format)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.9"
5
+ VERSION = "0.8.11"
6
6
  end
7
7
  end
@@ -10,7 +10,7 @@ module Lutaml
10
10
  super
11
11
  @namespace_set = Lutaml::Rdf::NamespaceSet.new
12
12
  @rdf_subject = nil
13
- @rdf_type = nil
13
+ @rdf_type = []
14
14
  @rdf_predicates = []
15
15
  @rdf_members = []
16
16
  end
@@ -24,20 +24,26 @@ module Lutaml
24
24
  end
25
25
 
26
26
  def type(value)
27
- @rdf_type = value
27
+ @rdf_type = Array(value)
28
28
  end
29
29
 
30
- def predicate(name, namespace:, to:, lang_tagged: false)
30
+ def predicate(name, namespace:, to:, lang_tagged: false,
31
+ uri_reference: false)
31
32
  @rdf_predicates << Lutaml::Rdf::MappingRule.new(
32
33
  name,
33
34
  namespace: namespace,
34
35
  to: to,
35
36
  lang_tagged: lang_tagged,
37
+ uri_reference: uri_reference,
36
38
  )
37
39
  end
38
40
 
39
- def members(attr_name)
40
- @rdf_members << Lutaml::Rdf::MemberRule.new(attr_name)
41
+ def members(attr_name, predicate_name: nil, namespace: nil)
42
+ @rdf_members << Lutaml::Rdf::MemberRule.new(
43
+ attr_name,
44
+ predicate_name: predicate_name,
45
+ namespace: namespace,
46
+ )
41
47
  end
42
48
 
43
49
  def mappings(_register_id = nil)
@@ -57,14 +63,14 @@ module Lutaml
57
63
  end
58
64
 
59
65
  def deep_dup
60
- self.class.new.tap do |new_mapping|
61
- new_mapping.instance_variable_set(:@namespace_set, @namespace_set)
62
- new_mapping.instance_variable_set(:@rdf_subject, @rdf_subject)
63
- new_mapping.instance_variable_set(:@rdf_type, @rdf_type)
64
- new_mapping.instance_variable_set(:@rdf_predicates,
65
- @rdf_predicates.dup)
66
- new_mapping.instance_variable_set(:@rdf_members, @rdf_members.dup)
67
- end
66
+ dup
67
+ end
68
+
69
+ def initialize_copy(source)
70
+ super
71
+ @rdf_type = source.rdf_type.dup
72
+ @rdf_predicates = source.rdf_predicates.dup
73
+ @rdf_members = source.rdf_members.dup
68
74
  end
69
75
  end
70
76
  end
@@ -3,14 +3,31 @@
3
3
  module Lutaml
4
4
  module Rdf
5
5
  class MappingRule
6
- attr_reader :predicate_name, :namespace, :to, :lang_tagged
6
+ attr_reader :predicate_name, :namespace, :to, :lang_tagged, :uri_reference
7
7
 
8
- def initialize(predicate_name, namespace:, to:, lang_tagged: false)
8
+ def initialize(predicate_name, namespace:, to:, lang_tagged: false,
9
+ uri_reference: false)
9
10
  validate!(predicate_name, namespace, to)
11
+ if lang_tagged && uri_reference
12
+ raise ArgumentError,
13
+ "lang_tagged and uri_reference are mutually exclusive"
14
+ end
15
+
10
16
  @predicate_name = predicate_name.to_s.freeze
11
17
  @namespace = namespace
12
18
  @to = to
13
19
  @lang_tagged = lang_tagged
20
+ @uri_reference = uri_reference
21
+ end
22
+
23
+ def kind
24
+ if uri_reference
25
+ :uri_reference
26
+ elsif lang_tagged
27
+ :lang_tagged
28
+ else
29
+ :plain
30
+ end
14
31
  end
15
32
 
16
33
  def uri
@@ -3,10 +3,27 @@
3
3
  module Lutaml
4
4
  module Rdf
5
5
  class MemberRule
6
- attr_reader :attr_name
6
+ attr_reader :attr_name, :predicate_name, :namespace
7
+
8
+ def initialize(attr_name, predicate_name: nil, namespace: nil)
9
+ if predicate_name && !namespace
10
+ raise ArgumentError,
11
+ "namespace is required when predicate_name is provided"
12
+ end
7
13
 
8
- def initialize(attr_name)
9
14
  @attr_name = attr_name.to_sym
15
+ @predicate_name = predicate_name
16
+ @namespace = namespace
17
+ end
18
+
19
+ def linked?
20
+ !!@predicate_name
21
+ end
22
+
23
+ def linked_predicate_uri
24
+ return nil unless linked?
25
+
26
+ @namespace[@predicate_name]
10
27
  end
11
28
  end
12
29
  end
@@ -3,22 +3,35 @@
3
3
  module Lutaml
4
4
  module Rdf
5
5
  class Transform < Lutaml::Model::Transform
6
- protected
7
-
8
6
  def resolve_subject_uri(mapping, instance)
9
7
  mapping.rdf_subject&.call(instance)
10
8
  end
11
9
 
12
- def resolve_type_uri(mapping)
13
- return unless mapping.rdf_type
10
+ def resolve_single_type_uri(mapping, type_value)
11
+ mapping.namespace_set.resolve_compact_iri(type_value)
12
+ end
13
+
14
+ def resolve_type_uris(mapping)
15
+ return [] unless mapping.rdf_type.any?
16
+
17
+ mapping.rdf_type.map { |t| resolve_single_type_uri(mapping, t) }
18
+ end
19
+
20
+ def each_member(instance, member_rule, &)
21
+ collection = Array(instance.public_send(member_rule.attr_name))
22
+ collection.each(&)
23
+ end
14
24
 
15
- mapping.namespace_set.resolve_compact_iri(mapping.rdf_type)
25
+ def member_mapping_for(member, format)
26
+ member.class.mappings[format]
16
27
  end
17
28
 
18
- def resolve_type_compact(mapping)
19
- mapping.rdf_type
29
+ def extract_language(value)
30
+ value.language_tag if value.is_a?(Lutaml::Rdf::LanguageTagged)
20
31
  end
21
32
 
33
+ protected
34
+
22
35
  def build_instance(attrs, options)
23
36
  child_register = Lutaml::Model::Register.resolve_for_child(
24
37
  model_class, lutaml_register
@@ -27,10 +40,6 @@ module Lutaml
27
40
  root_and_parent_assignment(instance, options)
28
41
  instance
29
42
  end
30
-
31
- def extract_language(value)
32
- value.language_tag if value.is_a?(Lutaml::Rdf::LanguageTagged)
33
- end
34
43
  end
35
44
  end
36
45
  end