Sha256: 351c68f12ad2df7e5710a5782119b8065bb11e59c7c1452d72ad9247bb77e5bb

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

module Comable
  class Migration < ActiveRecord::Migration
    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

    COMABLE_TYPES = %w( product stock customer order order_delivery order_detail )
    COMABLE_TYPES.each do |type|
      define_add_column_safety_method_for(type)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comable-0.0.3 lib/comable/migration.rb
comable-0.0.2 lib/comable/migration.rb
comable-0.0.1 lib/comable/migration.rb