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::GENERATOR_STATE_KEY, Model::Serialize::INTERNAL_ATTRIBUTES, Model::Serialize::LAZY_EMPTY_COLLECTION

Constants included from Model::Validation

Model::Validation::VALIDATING_KEY

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?, #define_singleton_attribute_methods, #extract_register_id, #finalize_deserialization, 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_in_reference_store, 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, #values_set_for, wrap_generator_state

Methods included from Model::Liquefiable

included, #to_liquid

Methods included from Model::Validation

#collect_validation_errors, #element_order, #format_element_sequences, new_registry, #order_names, #validate, validate, validate!, #validate!, #validate_helper, #validate_sequence!, visiting?

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?, #order_tracking_enabled?, #ordered?, #record_mutation, #record_mutation_collection

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



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



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



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



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



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

def type_name
  definition&.name
end