Skip to content

Attributes

Basic

attribute

ruby
attribute :uuid, from: String, to: :id, as: String, format: :uuid

string

ruby
string :uuid, to: :id

integer

ruby
integer :rating, min: 1, max: 10

float

ruby
float :rating

boolean

ruby
boolean :published

Options

The following options are available for the attribute method:

  • from;
  • to;
  • as;
  • format;
  • min;
  • max.

For helpers these options are also available, with the exception of the from option.

You can find out about supported values for format here.

Helpers

uuid

ruby
uuid :id
ruby
string :id, format: :uuid

money

ruby
money :box_office
ruby
integer :box_office_cents
string :box_office_currency

duration

ruby
duration :episode_duration
ruby
string :episode_duration, from: String, as: ActiveSupport::Duration, format: { from: :duration }

date

ruby
date :premiered_on
ruby
string :premiered_on, from: String, as: Date, format: { from: :date }

time

ruby
time :premiered_at
ruby
string :premiered_at, from: String, as: Time, format: { from: :time }

datetime

ruby
datetime :premiered_at
ruby
string :premiered_at, from: String, as: DateTime, format: { from: :datetime }