Module: MoneyAttribute::MigrationExtensions::SchemaStatements
- Includes:
- Helper
- Defined in:
- lib/money_attribute/migration_extensions/schema_statements.rb
Instance Method Summary collapse
- #add_money(table_name, accessor, options = {}) ⇒ Object
- #remove_money(table_name, accessor, options = {}) ⇒ Object
Instance Method Details
#add_money(table_name, accessor, options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/money_attribute/migration_extensions/schema_statements.rb', line 10 def add_money(table_name, accessor, = {}) amount_col, currency_col, amount_opts, currency_opts = parse_money_args(accessor, ) add_column(table_name, amount_col, amount_opts[:type], **amount_opts.except(:type)) add_column(table_name, currency_col, :string, **currency_opts) if currency_col end |
#remove_money(table_name, accessor, options = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/money_attribute/migration_extensions/schema_statements.rb', line 17 def remove_money(table_name, accessor, = {}) amount_col, currency_col, = parse_money_args(accessor, ) remove_column(table_name, amount_col) remove_column(table_name, currency_col) if currency_col end |