Sha256: e263a376a3b7e6e18930ba796e886bf3252dd5b97ee9b74667c596993e8c838c
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
require "lutaml/model" class SampleModelTag < Lutaml::Model::Serializable attribute :text, :string, default: -> { "" } xml do root "Tag" map_content to: :text end end class SampleModel < Lutaml::Model::Serializable attribute :name, :string, default: -> { "Anonymous" } attribute :age, :integer, default: -> { 18 } attribute :balance, :decimal, default: -> { BigDecimal("0.0") } attribute :tags, SampleModelTag, collection: true attribute :preferences, :hash, default: -> { { notifications: true } } attribute :status, :string, default: -> { "active" } attribute :large_number, :integer, default: -> { 0 } attribute :email, :string, default: -> { "example@example.com" } attribute :role, :string, values: %w[user admin guest], default: -> { "user" } xml do root "SampleModel" map_element "Name", to: :name map_element "Age", to: :age map_element "Balance", to: :balance map_element "Tags", to: :tags map_element "Preferences", to: :preferences map_element "Status", to: :status map_element "LargeNumber", to: :large_number map_element "Email", to: :email map_element "Role", to: :role end yaml do map "name", to: :name map "age", to: :age end end
Version data entries
4 entries across 4 versions & 1 rubygems