Class: Comable::Migration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/comable/migration.rb

Constant Summary collapse

COMABLE_TYPES =
%w( product stock customer order order_delivery order_detail )

Class Method Summary collapse

Class Method Details

.define_add_column_safety_method_for(type) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/comable/migration.rb', line 3

def self.define_add_column_safety_method_for(type)
  define_method "add_column_safety_to_#{type.to_s.pluralize}" do |column_name, type_name, options = {}|
    column_name_sym = column_name.to_sym
    return if Utusemi.config.map(type).attributes[column_name_sym]
    add_column Comable.const_get(type.to_s.classify).table_name, column_name_sym, type_name, options
  end
end