Module: MoneyAttribute::MigrationExtensions::TableDefinition

Includes:
Helper
Defined in:
lib/money_attribute/migration_extensions/table_definition.rb

Instance Method Summary collapse

Instance Method Details

#money(accessor, options = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/money_attribute/migration_extensions/table_definition.rb', line 10

def money(accessor, options = {})
  amount_col, currency_col, amount_opts, currency_opts = parse_money_args(accessor, options)

  column(amount_col, amount_opts[:type], **amount_opts.except(:type))
  column(currency_col, :string, **currency_opts) if currency_col
end

#remove_money(accessor, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/money_attribute/migration_extensions/table_definition.rb', line 17

def remove_money(accessor, options = {})
  amount_col, currency_col, = parse_money_args(accessor, options)

  remove_column(amount_col)
  remove_column(currency_col) if currency_col
end