Sha256: 692f7db4428ae4795ae7607e5d356fc15dac124b15e97d82c1137233c921e3ae

Contents?: true

Size: 542 Bytes

Versions: 1

Compression:

Stored size: 542 Bytes

Contents

module WithModel
  autoload :Base, "with_model/base"
  autoload :Dsl, "with_model/dsl"
  autoload :VERSION, "with_model/version"

  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

1 entries across 1 versions & 1 rubygems

Version Path
with_model-0.3 lib/with_model.rb