Sha256: b6e6d8f6ea87c8a029dc2f51635ad06d8d66e751b438becaabb84b7da7bbfc4e

Contents?: true

Size: 1022 Bytes

Versions: 2

Compression:

Stored size: 1022 Bytes

Contents

class Baza::InfoActiveRecord
  attr_reader :db

  def self.connection
    require "active_record"

    if RUBY_ENGINE == "jruby"
      require "/usr/share/java/mysql-connector-java.jar" if File.exists?("/usr/share/java/mysql-connector-java.jar")
      @conn_pool ||= ::ActiveRecord::Base.establish_connection(
        adapter: "mysql",
        host: "localhost",
        database: "baza",
        username: "shippa"
      )
      @conn ||= @conn_pool.connection
    else
      @conn_pool ||= ::ActiveRecord::Base.establish_connection(
        adapter: "mysql2",
        host: "localhost",
        database: "baza",
        username: "shippa"
      )
      @conn ||= @conn_pool.connection
    end

    return {pool: @conn_pool, conn: @conn}
  end

  def initialize
    data = Baza::InfoActiveRecord.connection

    @db = Baza::Db.new(
      type: :active_record,
      conn: data[:conn]
    )
  end

  def before
    @db.tables.list.each do |name, table|
      table.drop
    end
  end

  def after
    @db.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baza-0.0.17 spec/info_active_record_shippable.rb
baza-0.0.16 spec/info_active_record_shippable.rb