annotation XMLT::Attributes

Overview

Defines the XML attributes to be serialized with the property it is annotated with. This accepts key-value pairs that will be serialized directly with the property.

Example

require "xmlt"

struct Shape
  include XMLT::Serializable

  @[XMLT::Attributes(dimension: 2)]
  property name : String

  def initialize(@name); end
end

square = Shape.new "square"
puts square.to_xml # => <Shape><name dimension="2">square</name></Shape>

Defined in:

annotations.cr