class Rethinker::Database

Attributes

connection[RW]

Public Class Methods

new(connection) click to toggle source
# File lib/rethinker/database.rb, line 6
def initialize(connection)
  self.connection = connection
end
truncate_table!(table_name) click to toggle source
# File lib/rethinker/database.rb, line 35
def self.truncate_table!(table_name)
  Rethinker.run { RethinkDB::RQL.new.table(table_name).delete }
end

Public Instance Methods

purge!(options={}) click to toggle source
# File lib/rethinker/database.rb, line 14
def purge!(options={})
  if options[:drop]
    connection.db_drop(database_name)
  else
    # truncating each table is much faster
    table_list.each do |table_name|
      self.class.truncate_table!(table_name)
    end
  end
rescue RuntimeError => e
  raise e unless e.message =~ /No entry with that name/
end
raw() click to toggle source
# File lib/rethinker/database.rb, line 10
def raw
  @raw ||= RethinkDB::RQL.new.db(database_name)
end