Class: Lutaml::Xsd::Schema

Inherits:
Model::Serializable
  • Object
show all
Defined in:
lib/lutaml/xsd/schema.rb

Overview

rubocop:disable Metrics/ClassLength

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_in_progress(location) ⇒ Object



169
170
171
# File 'lib/lutaml/xsd/schema.rb', line 169

def add_in_progress(location)
  in_progress << location
end

.in_progressObject



161
162
163
# File 'lib/lutaml/xsd/schema.rb', line 161

def in_progress
  @in_progress ||= []
end

.in_progress?(location) ⇒ Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/lutaml/xsd/schema.rb', line 165

def in_progress?(location)
  in_progress.include?(location)
end

.processed_schemasObject



147
148
149
# File 'lib/lutaml/xsd/schema.rb', line 147

def processed_schemas
  @processed_schemas ||= {}
end

.remove_in_progress(location) ⇒ Object



173
174
175
# File 'lib/lutaml/xsd/schema.rb', line 173

def remove_in_progress(location)
  in_progress.delete(location)
end

.reset_processed_schemasObject



143
144
145
# File 'lib/lutaml/xsd/schema.rb', line 143

def reset_processed_schemas
  @processed_schemas = {}
end

.schema_processed(location, schema) ⇒ Object



155
156
157
158
159
# File 'lib/lutaml/xsd/schema.rb', line 155

def schema_processed(location, schema)
  return if location.nil?

  processed_schemas[location] = schema
end

.schema_processed?(location) ⇒ Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/lutaml/xsd/schema.rb', line 151

def schema_processed?(location)
  processed_schemas[location]
end

Instance Method Details

#import_from_schema(model, value) ⇒ Object



58
59
60
61
62
# File 'lib/lutaml/xsd/schema.rb', line 58

def import_from_schema(model, value)
  value.each do |schema|
    setup_import_and_include("import", model, schema, namespace: schema["attributes"]["namespace"])
  end
end

#import_to_schema(model, parent, _doc) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/lutaml/xsd/schema.rb', line 64

def import_to_schema(model, parent, _doc)
  return if model.imported

  model.imported = true
  model.imports.each do |imported_schema|
    parent.add_child(imported_schema.to_xml)
  end
end

#include_from_schema(model, value) ⇒ Object



73
74
75
76
77
# File 'lib/lutaml/xsd/schema.rb', line 73

def include_from_schema(model, value)
  value.each do |schema|
    setup_import_and_include("include", model, schema)
  end
end

#include_to_schema(model, parent, _doc) ⇒ Object



79
80
81
82
83
84
# File 'lib/lutaml/xsd/schema.rb', line 79

def include_to_schema(model, parent, _doc)
  model.includes.each_with_index do |schema_hash, index|
    parent.add_child(schema_hash.to_xml)
    model.includes.delete_at(index)
  end
end