Sha256: d747c10a3aaa7a06a8809b19e427bf4747f4ea600d4f44a53e577fc307e068a6

Contents?: true

Size: 465 Bytes

Versions: 2

Compression:

Stored size: 465 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) rescue nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
with_model-0.2.3 lib/with_model.rb
with_model-0.2.2 lib/with_model.rb