Class: Lutaml::Xml::Schema::Xsd::SchemaLocationMapping
- Inherits:
-
Model::Serializable
- Object
- Model::Serializable
- Lutaml::Xml::Schema::Xsd::SchemaLocationMapping
- Defined in:
- lib/lutaml/xml/schema/xsd/schema_location_mapping.rb
Overview
Represents a schema location mapping for resolving import/include paths
Constant Summary
Constants included from Model::Serialize
Model::Serialize::DEFAULT_VALUE_MAP, Model::Serialize::INTERNAL_ATTRIBUTES, Model::Serialize::LAZY_EMPTY_COLLECTION
Instance Attribute Summary
Attributes included from Model::Serialize
#lutaml_parent, #lutaml_register, #lutaml_root
Class Method Summary collapse
-
.from_hash(mapping) ⇒ SchemaLocationMapping
Convert hash-based mapping to SchemaLocationMapping instance.
Instance Method Summary collapse
-
#initialize(attributes = nil, from: nil, to: nil, pattern: nil) ⇒ SchemaLocationMapping
constructor
Override initialize to auto-detect Regexp patterns Supports both hash argument (for Lutaml::Model) and keyword arguments.
-
#to_glob_format ⇒ Hash
Convert to hash format compatible with Glob.schema_mappings.
Methods included from Model::Serialize
#attr_value, #attribute_exist?, #extract_register_id, included, #init_deserialization_state, #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
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
Constructor Details
#initialize(attributes = nil, from: nil, to: nil, pattern: nil) ⇒ SchemaLocationMapping
Override initialize to auto-detect Regexp patterns Supports both hash argument (for Lutaml::Model) and keyword arguments
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lutaml/xml/schema/xsd/schema_location_mapping.rb', line 30 def initialize(attributes = nil, from: nil, to: nil, pattern: nil, **) # Handle hash argument from Lutaml::Model deserialization if attributes.is_a?(Hash) from = attributes[:from] || attributes["from"] to = attributes[:to] || attributes["to"] pattern = attributes[:pattern] || attributes["pattern"] end # Auto-detect if from is a Regexp detected_pattern = from.is_a?(Regexp) # Convert Regexp to source string for storage from_str = detected_pattern ? from.source : from # Use explicit pattern flag if provided, otherwise use detected value final_pattern = pattern.nil? ? detected_pattern : pattern super(from: from_str, to: to, pattern: final_pattern, **) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize
Class Method Details
.from_hash(mapping) ⇒ SchemaLocationMapping
Convert hash-based mapping to SchemaLocationMapping instance
54 55 56 57 58 59 60 |
# File 'lib/lutaml/xml/schema/xsd/schema_location_mapping.rb', line 54 def self.from_hash(mapping) from = mapping[:from] || mapping["from"] to = mapping[:to] || mapping["to"] pattern = mapping[:pattern] || mapping["pattern"] new(from: from, to: to, pattern: pattern) end |
Instance Method Details
#to_glob_format ⇒ Hash
Convert to hash format compatible with Glob.schema_mappings
64 65 66 67 68 69 |
# File 'lib/lutaml/xml/schema/xsd/schema_location_mapping.rb', line 64 def to_glob_format { from: pattern ? Regexp.new(from) : from, to: to, } end |