Skip to content

annotation Athena::ORM::Annotations::Embeddable #

Marks a type as embeddable: a value object whose properties are stored as columns of the table of each entity that embeds it.

Unlike a custom AORM::Types::Type, which stores a value object in a single column, an embeddable spreads it over several columns that can each be queried and indexed. Unlike mapped properties shared through a module, an embeddable is its own object, and an entity can embed it more than once:

@[AORMA::Embeddable]
record Money, amount : BigDecimal, currency : String

@[AORMA::Entity]
class Order < AORM::Entity
  # ...

  property total : Money # Stored in the `total_amount` and `total_currency` columns
  property tax : Money   # Stored in the `tax_amount` and `tax_currency` columns
end

Todo

Not supported yet. In the meantime, store a value object that fits in one column with a custom AORM::Types::Type, or map its values as separate columns of the entity.