Sha256: f201961bfc6c3edceff228092db6fde01a6bc804e4aa72a52f0cf1fb7c6a3b31

Contents?: true

Size: 454 Bytes

Versions: 3

Compression:

Stored size: 454 Bytes

Contents

require "with_model/dsl"

module WithModel
  def with_model(name, &block)
    Dsl.new(name, self).tap { |dsl| dsl.instance_eval(&block) }.execute
  end

  def with_table(name, options = {}, &block)
    connection = ActiveRecord::Base.connection
    before do
      connection.drop_table(name) if connection.table_exists?(name)
      connection.create_table(name, options, &block)
    end

    after do
      connection.drop_table(name)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
with_model-0.2.6 lib/with_model.rb
with_model-0.2.5 lib/with_model.rb
with_model-0.2.4 lib/with_model.rb