Class: Lutaml::Model::Schema::XmlCompiler::Attribute
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::XmlCompiler::Attribute
- Defined in:
- lib/lutaml/model/schema/xml_compiler/attribute.rb
Constant Summary collapse
- TEMPLATE =
ERB.new("<%= indent %>attribute :<%= resolved_name %>, :<%= resolved_type %>\n", trim_mode: "-")
- XML_MAPPING_TEMPLATE =
ERB.new("<%= indent %>map_attribute :<%= resolved_name(change_case: false) %>, to: :<%= resolved_name %><%= namespace_prefix_option %>\n", trim_mode: "-")
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name: nil, ref: nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #required_files ⇒ Object
- #to_attributes(indent) ⇒ Object
- #to_xml_mapping(indent) ⇒ Object
Constructor Details
#initialize(name: nil, ref: nil) ⇒ Attribute
Returns a new instance of Attribute.
22 23 24 25 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 22 def initialize(name: nil, ref: nil) @name = name @ref = ref end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
8 9 10 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 8 def default @default end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 8 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 8 def name @name end |
#ref ⇒ Object
Returns the value of attribute ref.
8 9 10 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 8 def ref @ref end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 8 def type @type end |
Instance Method Details
#required_files ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 39 def required_files return if skippable? raw_type = resolved_type(change_case: false) if raw_type == "decimal" "require \"bigdecimal\"" elsif !SimpleType.skippable?(raw_type) "require_relative \"#{Utils.snake_case(raw_type)}\"" end end |
#to_attributes(indent) ⇒ Object
27 28 29 30 31 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 27 def to_attributes(indent) return if skippable? TEMPLATE.result(binding) end |
#to_xml_mapping(indent) ⇒ Object
33 34 35 36 37 |
# File 'lib/lutaml/model/schema/xml_compiler/attribute.rb', line 33 def to_xml_mapping(indent) return if skippable? XML_MAPPING_TEMPLATE.result(binding) end |