Module: MoneyRails::ActiveRecord::MigrationExtensions::Table

Defined in:
lib/money-rails/active_record/migration_extensions/table.rb,
lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb

Instance Method Summary collapse

Instance Method Details

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



5
6
7
8
9
10
11
# File 'lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb', line 5

def monetize(accessor, options={})
  [:amount, :currency].each do |attribute|
    column_present, _, *opts = OptionsExtractor.extract attribute, :no_table, accessor, options
    constraints = opts.pop
    column(*opts, **constraints) if column_present
  end
end

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



5
6
7
# File 'lib/money-rails/active_record/migration_extensions/table.rb', line 5

def money(accessor, options={})
  monetize(accessor, options)
end

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



13
14
15
16
17
18
# File 'lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb', line 13

def remove_monetize(accessor, options={})
  [:amount, :currency].each do |attribute|
    column_present, _, column_name, _, _ =  OptionsExtractor.extract attribute, :no_table, accessor, options
    remove column_name if column_present
  end
end

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



9
10
11
# File 'lib/money-rails/active_record/migration_extensions/table.rb', line 9

def remove_money(accessor, options={})
  remove_monetize(accessor, options)
end