Class: Lutaml::Xml::Schema::Xsd::TypeResolutionResult

Inherits:
Model::Serializable show all
Defined in:
lib/lutaml/xml/schema/xsd/type_resolution_result.rb

Overview

Represents the result of resolving a qualified type name

Constant Summary

Constants included from Model::Serialize

Model::Serialize::DEFAULT_VALUE_MAP, Model::Serialize::INTERNAL_ATTRIBUTES, Model::Serialize::LAZY_EMPTY_COLLECTION

Instance Attribute Summary collapse

Attributes included from Model::Serialize

#lutaml_parent, #lutaml_register, #lutaml_root

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::Serialize

#attr_value, #attribute_exist?, #extract_register_id, included, #init_deserialization_state, #initialize, #key_exist?, #key_value, #method_missing, #prepare_instance_format_options, #pretty_print_instance_variables, register_format_mapping_method, register_from_format_method, register_to_format_method, #respond_to_missing?, #to_format, #to_yaml_hash, #using_default?, #using_default_for, #validate_attribute!, #validate_root_mapping!, #value_map, #value_set_for

Methods included from Model::Liquefiable

included, #to_liquid

Methods included from Model::Validation

#format_element_sequences, #order_names, #validate, #validate!, #validate_helper, #validate_sequence!

Methods included from Model::ComparableModel

#already_compared?, #attributes_hash, #calculate_hash, #comparison_key, #eql?, #hash, included, #same_class?

Methods included from Model::Serialize::Builder

#initialize, #mixed_content?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize

Instance Attribute Details

#definitionObject

The resolved type definition (SimpleType, ComplexType, Element, etc.) Note: This is not serialized in YAML as it’s a complex object reference



23
24
25
# File 'lib/lutaml/xml/schema/xsd/type_resolution_result.rb', line 23

def definition
  @definition
end

Class Method Details

.failure(qname:, error_message:, namespace: nil, local_name: nil, resolution_path: []) ⇒ TypeResolutionResult

Create a failed resolution result

Parameters:

  • qname (String)

    The original qualified name

  • namespace (String, nil) (defaults to: nil)

    The attempted namespace URI

  • local_name (String, nil) (defaults to: nil)

    The local type name

  • error_message (String)

    The error message

  • resolution_path (Array<String>) (defaults to: [])

    Steps taken before failure

Returns:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/lutaml/xml/schema/xsd/type_resolution_result.rb', line 93

def self.failure(qname:, error_message:, namespace: nil, local_name: nil,
      resolution_path: [])
  result = new(
    resolved: false,
    qname: qname,
    namespace: namespace,
    local_name: local_name,
    schema_file: nil,
    resolution_path: resolution_path,
    error_message: error_message,
  )
  # Set definition separately since it's attr_accessor, not attribute
  result.definition = nil
  result
end

.success(qname:, namespace:, local_name:, definition:, schema_file:, resolution_path: []) ⇒ TypeResolutionResult

Create a successful resolution result

Parameters:

  • qname (String)

    The original qualified name

  • namespace (String)

    The resolved namespace URI

  • local_name (String)

    The local type name

  • definition (Base)

    The type definition object

  • schema_file (String)

    The source schema file

  • resolution_path (Array<String>) (defaults to: [])

    Steps taken to resolve

Returns:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/lutaml/xml/schema/xsd/type_resolution_result.rb', line 70

def self.success(qname:, namespace:, local_name:, definition:,
      schema_file:, resolution_path: [])
  result = new(
    resolved: true,
    qname: qname,
    namespace: namespace,
    local_name: local_name,
    schema_file: schema_file,
    resolution_path: resolution_path,
    error_message: nil,
  )
  # Set definition separately since it's attr_accessor, not attribute
  result.definition = definition
  result
end

Instance Method Details

#resolved?Boolean

Check if the type was successfully resolved

Returns:

  • (Boolean)


46
47
48
# File 'lib/lutaml/xml/schema/xsd/type_resolution_result.rb', line 46

def resolved?
  resolved == true
end

#type_classString?

Get the type class name if definition is available

Returns:

  • (String, nil)


58
59
60
# File 'lib/lutaml/xml/schema/xsd/type_resolution_result.rb', line 58

def type_class
  definition&.class&.name
end

#type_nameString?

Get the type name from the definition if available

Returns:

  • (String, nil)


52
53
54
# File 'lib/lutaml/xml/schema/xsd/type_resolution_result.rb', line 52

def type_name
  definition&.name
end