Module: VrowserModel
- Included in:
- Vrowser
- Defined in:
- lib/vrowser.rb
Class Method Summary collapse
Class Method Details
.connect(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vrowser.rb', line 12 def self.connect(={}) logger = .delete(:logger) Sequel::Model.plugin :schema Sequel::Model.plugin :timestamps, :update_on_create => true Sequel::Model.plugin :force_encoding, 'utf-8' if logger Sequel.connect(, :loggers => [logger]) else Sequel.connect() end self.define_models Servers.plugin :timestamps, :create=>:created_at, :update=>:updated_at end |
.define_models ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vrowser.rb', line 28 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, :default => nil, :null => true timestamp :updated_at, :default => nil, :null => true end create_table end end } end |