class

MartenMoney::DB::Field::Money

Inherits Marten::DB::Field::Base < Reference < Object

Constructors

new(id : String, blank = false, null = false, default : ::Money | Nil = nil, amount_field_id : String | Symbol | Nil = nil, currency_field_id : String | Symbol | Nil = nil, fixed_currency : String | Symbol | Nil = nil, store_currency : Bool | Nil = nil)
Source

Class methods

fractional_to_i64(value : ::Money, field_id : String) : Int64

Converts value into an Int64 amount of minor units for the generated amount field.

The exact amount is derived from Money#amount because Money#fractional silently drops sub-minor-unit precision when Money.infinite_precision? is enabled. Values that cannot be represented exactly as an Int64 raise an ArgumentError.

Source

Instance methods

db_column

Returns the name of the column associated with the considered field.

Source
default

Returns nil to keep the virtual field out of Marten's default value initialization.

The generated amount and currency fields own the persisted defaults. The configured default remains available as metadata through #money_default.

Source
fixed_currency

Returns the configured fixed currency, if any.

Source
from_db(value) : ::Money | Nil

Converts the raw DB value to the corresponding field value.

Source
from_db_result_set(result_set : ::DB::ResultSet) : ::Money | Nil

Extracts the field value from a DB result set and returns the right object corresponding to this value.

Source
money_default

Returns the configured default Money value, if any.

Source
perform_validation(record : Marten::Model)

:nodoc:

Source
to_column

Returns a migration column object corresponding to the field at hand.

Source
to_db(value) : ::DB::Any

Converts the field value to the corresponding DB value.

Source