Module: MoneyAttribute::MigrationExtensions::TableDefinition
- Includes:
- Helper
- Defined in:
- lib/money_attribute/migration_extensions/table_definition.rb
Overview
Migration DSL methods for use inside create_table and change_table
blocks.
Included into both ActiveRecord::ConnectionAdapters::TableDefinition
and ActiveRecord::ConnectionAdapters::Table.
Constant Summary
Constants included from Helper
Helper::AMOUNT_CONFIG, Helper::CURRENCY_DEFAULT_LIMIT, Helper::CURRENCY_MIN_LIMIT
Instance Attribute Summary
Attributes included from Helper
#AMOUNT_CONFIG, #CURRENCY_DEFAULT_LIMIT, #CURRENCY_MIN_LIMIT
Instance Method Summary collapse
-
#money_amount(accessor, options = {}) ⇒ void
Adds a single amount column within a table definition.
-
#money_attribute(accessor, options = {}) ⇒ void
Adds amount and currency columns within a table definition.
-
#remove_money_amount(accessor, options = {}) ⇒ void
Removes a single amount column within a table definition.
-
#remove_money_attribute(accessor, options = {}) ⇒ void
Removes amount and currency columns within a table definition.
Instance Method Details
#money_amount(accessor, options = {}) ⇒ void
This method returns an undefined value.
Adds a single amount column within a table definition.
76 77 78 79 80 |
# File 'lib/money_attribute/migration_extensions/table_definition.rb', line 76 def money_amount(accessor, = {}) amount_column, amount_opts = parse_money_amount_args(accessor, ) column(amount_column, amount_opts[:type], **amount_opts.except(:type)) end |
#money_attribute(accessor, options = {}) ⇒ void
This method returns an undefined value.
Adds amount and currency columns within a table definition.
41 42 43 44 45 46 |
# File 'lib/money_attribute/migration_extensions/table_definition.rb', line 41 def money_attribute(accessor, = {}) amount_column, currency_column, amount_opts, currency_opts = parse_money_args(accessor, ) column(amount_column, amount_opts[:type], **amount_opts.except(:type)) column(currency_column, :string, **currency_opts) end |
#remove_money_amount(accessor, options = {}) ⇒ void
This method returns an undefined value.
Removes a single amount column within a table definition.
88 89 90 91 92 |
# File 'lib/money_attribute/migration_extensions/table_definition.rb', line 88 def remove_money_amount(accessor, = {}) amount_column, = parse_money_amount_args(accessor, ) remove_column(amount_column) end |
#remove_money_attribute(accessor, options = {}) ⇒ void
This method returns an undefined value.
Removes amount and currency columns within a table definition.
55 56 57 58 59 60 |
# File 'lib/money_attribute/migration_extensions/table_definition.rb', line 55 def remove_money_attribute(accessor, = {}) amount_column, currency_column, = parse_money_args(accessor, ) remove_column(amount_column) remove_column(currency_column) end |