Class: Lutaml::Model::Sequence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Sequence

Returns a new instance of Sequence.



7
8
9
10
# File 'lib/lutaml/model/sequence.rb', line 7

def initialize(model)
  @attributes = []
  @model = model
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/lutaml/model/sequence.rb', line 5

def attributes
  @attributes
end

#modelObject

Returns the value of attribute model.



4
5
6
# File 'lib/lutaml/model/sequence.rb', line 4

def model
  @model
end

Instance Method Details

#attribute(name, type, options = {}) ⇒ Object



12
13
14
15
# File 'lib/lutaml/model/sequence.rb', line 12

def attribute(name, type, options = {})
  options[:sequence] = self
  @model.attribute(name, type, options)
end

#import_model_mappings(model) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/lutaml/model/sequence.rb', line 25

def import_model_mappings(model)
  return import_mappings_later(model) if later_importable?(model)
  raise Lutaml::Model::ImportModelWithRootError.new(model) if model.root?

  @model.import_model_mappings(model)
  @attributes.concat(Utils.deep_dup(model.mappings_for(:xml).elements))
end

#map_allObject



41
42
43
# File 'lib/lutaml/model/sequence.rb', line 41

def map_all(*)
  raise Lutaml::Model::UnknownSequenceMappingError.new("map_all")
end

#map_attributeObject



33
34
35
# File 'lib/lutaml/model/sequence.rb', line 33

def map_attribute(*)
  raise Lutaml::Model::UnknownSequenceMappingError.new("map_attribute")
end

#map_contentObject



37
38
39
# File 'lib/lutaml/model/sequence.rb', line 37

def map_content(*)
  raise Lutaml::Model::UnknownSequenceMappingError.new("map_content")
end

#map_element(name, **kwargs) ⇒ Object



21
22
23
# File 'lib/lutaml/model/sequence.rb', line 21

def map_element(name, **kwargs)
  @attributes << @model.map_element(name, **kwargs)
end

#sequence(&block) ⇒ Object



17
18
19
# File 'lib/lutaml/model/sequence.rb', line 17

def sequence(&block)
  instance_eval(&block)
end

#validate_content!(element_order, model_class) ⇒ Object



45
46
47
48
49
50
# File 'lib/lutaml/model/sequence.rb', line 45

def validate_content!(element_order, model_class)
  validate_sequence!(
    extract_defined_order(model_class.attributes),
    element_order,
  )
end