Sha256: fcbaee9368a41eeb3e7895fa63e6c87f72a37f1d536446980fc675c9821bfa17

Contents?: true

Size: 477 Bytes

Versions: 7

Compression:

Stored size: 477 Bytes

Contents

require 'active_record'

module WithModel
  class Table
    def initialize name, options = {}, &block
      @name = name.freeze
      @options = options.freeze
      @block = block
    end

    def create
      connection = ActiveRecord::Base.connection
      connection.drop_table(@name) if connection.table_exists?(@name)
      connection.create_table(@name, @options, &@block)
    end

    def destroy
      ActiveRecord::Base.connection.drop_table(@name)
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/with_model-1.2.1/lib/with_model/table.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/with_model-1.2.1/lib/with_model/table.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/with_model-1.2.1/lib/with_model/table.rb
with_model-1.2.1 lib/with_model/table.rb
with_model-1.2.0 lib/with_model/table.rb
with_model-1.1.0 lib/with_model/table.rb
with_model-1.0.0 lib/with_model/table.rb