Class: Lutaml::Model::Sequence
- Inherits:
-
Object
- Object
- Lutaml::Model::Sequence
- Defined in:
- lib/lutaml/model/sequence.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #attribute(name, type, options = {}) ⇒ Object
-
#initialize(model) ⇒ Sequence
constructor
A new instance of Sequence.
- #map_all ⇒ Object
- #map_attribute ⇒ Object
- #map_content ⇒ Object
- #map_element(name, to: nil, render_nil: false, render_default: false, with: {}, delegate: nil, cdata: false, namespace: nil, prefix: nil, transform: {}) ⇒ Object
- #sequence(&block) ⇒ Object
- #validate_content!(element_order) ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/lutaml/model/sequence.rb', line 5 def attributes @attributes end |
#model ⇒ Object
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, = {}) [:sequence] = self @model.attribute(name, type, ) end |
#map_all ⇒ Object
55 56 57 |
# File 'lib/lutaml/model/sequence.rb', line 55 def map_all(*) raise Lutaml::Model::UnknownSequenceMappingError.new("map_all") end |
#map_attribute ⇒ Object
47 48 49 |
# File 'lib/lutaml/model/sequence.rb', line 47 def map_attribute(*) raise Lutaml::Model::UnknownSequenceMappingError.new("map_attribute") end |
#map_content ⇒ Object
51 52 53 |
# File 'lib/lutaml/model/sequence.rb', line 51 def map_content(*) raise Lutaml::Model::UnknownSequenceMappingError.new("map_content") end |
#map_element(name, to: nil, render_nil: false, render_default: false, with: {}, delegate: nil, cdata: false, namespace: nil, prefix: nil, transform: {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lutaml/model/sequence.rb', line 21 def map_element( name, to: nil, render_nil: false, render_default: false, with: {}, delegate: nil, cdata: false, namespace: nil, prefix: nil, transform: {} ) @attributes << @model.map_element( name, to: to, render_nil: render_nil, render_default: render_default, with: with, delegate: delegate, cdata: cdata, namespace: namespace, prefix: prefix, transform: transform, ) 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) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/lutaml/model/sequence.rb', line 59 def validate_content!(element_order) defined_order = @attributes.map { |rule| rule.name.to_s } start_index = element_order.index(defined_order.first) defined_order.each.with_index(start_index) do |element, i| unless element_order[i] == element raise Lutaml::Model::IncorrectSequenceError.new(element, element_order[i]) end end end |