Module: MoneyRails::ActiveRecord::MigrationExtensions::SchemaStatements
- Defined in:
- lib/money-rails/active_record/migration_extensions/schema_statements.rb,
lib/money-rails/active_record/migration_extensions/schema_statements_pg_rails4.rb
Instance Method Summary collapse
- #add_monetize(table_name, accessor, options = {}) ⇒ Object
- #add_money(table_name, accessor, options = {}) ⇒ Object
- #remove_monetize(table_name, accessor, options = {}) ⇒ Object
- #remove_money(table_name, accessor, options = {}) ⇒ Object
Instance Method Details
#add_monetize(table_name, accessor, options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/money-rails/active_record/migration_extensions/schema_statements_pg_rails4.rb', line 5 def add_monetize(table_name, accessor, ={}) [:amount, :currency].each do |attribute| column_present, *opts = OptionsExtractor.extract attribute, table_name, accessor, constraints = opts.pop add_column(*opts, **constraints) if column_present end end |
#add_money(table_name, accessor, options = {}) ⇒ Object
5 6 7 |
# File 'lib/money-rails/active_record/migration_extensions/schema_statements.rb', line 5 def add_money(table_name, accessor, ={}) add_monetize(table_name, accessor, ) end |
#remove_monetize(table_name, accessor, options = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/money-rails/active_record/migration_extensions/schema_statements_pg_rails4.rb', line 13 def remove_monetize(table_name, accessor, ={}) [:amount, :currency].each do |attribute| column_present, table_name, column_name, type, _ = OptionsExtractor.extract attribute, table_name, accessor, remove_column table_name, column_name, type if column_present end end |
#remove_money(table_name, accessor, options = {}) ⇒ Object
9 10 11 |
# File 'lib/money-rails/active_record/migration_extensions/schema_statements.rb', line 9 def remove_money(table_name, accessor, ={}) remove_monetize(table_name, accessor, ) end |