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
- #monetize(accessor, options = {}) ⇒ Object
- #money(accessor, options = {}) ⇒ Object
- #remove_monetize(accessor, options = {}) ⇒ Object
- #remove_money(accessor, options = {}) ⇒ Object
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, ={}) [:amount, :currency].each do |attribute| column_present, _, *opts = OptionsExtractor.extract attribute, :no_table, accessor, 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, ={}) monetize(accessor, ) 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, ={}) [:amount, :currency].each do |attribute| column_present, _, column_name, _, _ = OptionsExtractor.extract attribute, :no_table, accessor, 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, ={}) remove_monetize(accessor, ) end |