Sha256: 16dd2cb26449f191e5592b54761a89d4cac0fc403ee2bd574a458765cee639f1

Contents?: true

Size: 1.12 KB

Versions: 37

Compression:

Stored size: 1.12 KB

Contents

module RailsDb
  class Database
    extend Connection

    class << self
      delegate :count,       to: :adapter
      delegate :truncate,    to: :adapter
      delegate :delete,      to: :adapter
      delegate :execute,     to: :adapter
      delegate :select,      to: :adapter
      delegate :explain,     to: :adapter
      delegate :exec_query,  to: :adapter
      delegate :primary_key, to: :adapter
      delegate :indexes,     to: :adapter
    end

    def self.tables
      connection.tables.sort - ['schema_migrations']
    end

    def self.accessible_tables
      tables = Database.tables
      if Array.wrap(RailsDb.white_list_tables) != []
        tables = tables & RailsDb.white_list_tables
      end
      if Array.wrap(RailsDb.black_list_tables) != []
        tables = tables - RailsDb.black_list_tables
      end
      tables
    end

    def self.adapter
      case connection.class.to_s
      when /Mysql/
        RailsDb::Adapters::Mysql
      when /Postgre/
        RailsDb::Adapters::Postgres
      when /SQLite/
        RailsDb::Adapters::Sqlite
      else
        RailsDb::Adapters::BaseAdapter
      end
    end

  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
rails_db-2.4.4 lib/rails_db/database.rb
rails_db-2.4.3 lib/rails_db/database.rb
rails_db-2.4.2 lib/rails_db/database.rb
rails_db-2.4.1 lib/rails_db/database.rb
rails_db-2.4.0 lib/rails_db/database.rb
rails_db-2.3.1 lib/rails_db/database.rb
rails_db-2.3.0 lib/rails_db/database.rb
rails_db-2.2.1 lib/rails_db/database.rb
rails_db-2.2.0 lib/rails_db/database.rb
rails_db-2.1.1 lib/rails_db/database.rb
rails_db-2.1.0 lib/rails_db/database.rb
rails_db-2.0.6 lib/rails_db/database.rb
rails_db-2.0.5 lib/rails_db/database.rb
rails_db-2.0.4 lib/rails_db/database.rb
xplore-0.0.1.alpha lib/rails_db/database.rb
rails_db-2.0.3 lib/rails_db/database.rb
rails_db-2.0.2 lib/rails_db/database.rb
rails_db-2.0.1 lib/rails_db/database.rb
rails_db-2.0.0 lib/rails_db/database.rb
rails_db-1.6.0 lib/rails_db/database.rb