Class: Lutaml::Model::Serialize::DeserializationContext

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/serialize/deserialization_context.rb

Overview

Encapsulates the parent-to-child options propagation contract.

During deserialization, a parent passes context to its children via an options Hash. Only certain keys are safe to propagate — parent-internal keys (resolved_type, namespace_uri, converted) must be stripped so children derive their own context.

This class is the single source of truth for which keys propagate, replacing scattered CHILD_PROPAGATION_KEYS constants and ad-hoc ‘.slice` calls.

Usage:

child_options = DeserializationContext.propagate(options).merge(register: register)
klass.apply_mappings(value, format, child_options)

Constant Summary collapse

PROPAGATION_KEYS =

Keys that are safe to propagate from parent to child deserialization.

Parent-internal keys (namespace_uri, resolved_type, converted, mappings) are intentionally excluded — children must derive their own context.

%i[
  lutaml_parent
  lutaml_root
  default_namespace
  import_declaration_plan
  polymorphic
  collection
  render_empty
  render_nil
  cdata
].freeze

Class Method Summary collapse

Class Method Details

.propagate(options) ⇒ Hash

Extract propagable keys from a parent options hash.

Returns a new Hash containing only the keys safe for child deserialization. Parent-internal keys are excluded.

Parameters:

  • options (Hash)

    The parent’s options hash

Returns:

  • (Hash)

    A new hash with only propagable keys



44
45
46
# File 'lib/lutaml/model/serialize/deserialization_context.rb', line 44

def self.propagate(options)
  options.slice(*PROPAGATION_KEYS)
end