class Squab::DB

Attributes

events[RW]
threadsafe[RW]

Public Class Methods

new(conn_string) click to toggle source
# File lib/squab/db.rb, line 10
def initialize(conn_string)
  @db = Sequel.connect(conn_string)
  if not @db.table_exists?('events')
    bootstrap
  end
  # SQLite is not threadsafe
  @threadsafe = @db.database_type != :sqlite
  @events = @db.from(:events)
end

Public Instance Methods

bootstrap() click to toggle source
# File lib/squab/db.rb, line 20
def bootstrap
  @db.create_table :events do
      primary_key :id
      String :uid
      String :value
      String :url
      String :source
      Float :date
      Boolean :deleted
      index :uid
      index :date
      index :source
      index :deleted
  end
end