Module: VrowserModel

Included in:
Vrowser
Defined in:
lib/vrowser.rb

Class Method Summary collapse

Class Method Details

.connect(options = {}) ⇒ Object



11
12
13
14
15
16
# File 'lib/vrowser.rb', line 11

def self.connect(options={})
  Sequel::Model.plugin(:schema)
  Sequel.connect(options)
  self.define_models
  Servers.plugin :timestamps, :create=>:created_at, :update=>:updated_at
end

.define_modelsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vrowser.rb', line 18

def self.define_models
  module_eval %{
    class Servers < Sequel::Model
      unless table_exists?
        set_schema do
          primary_key :id
          string :name
          string :host, :unique => true
          string :status
          integer :ping
          string :num_players
          string :type
          string :map
          string :players
          timestamp :created_at
          timestamp :updated_at
        end
        create_table
      end
    end
  }
end