Sha256: 00780ed91637ee0223685b1699ea7f5aa618eb56a4a2875a8167da2ee5192c84

Contents?: true

Size: 780 Bytes

Versions: 6

Compression:

Stored size: 780 Bytes

Contents

module Timetrap
  class Entry < Sequel::Model
    plugin :schema

    def start= time
      self[:start]= Chronic.parse(time) || time
    end

    def end= time
      self[:end]= Chronic.parse(time) || time
    end

    def self.sheets
      map{|e|e.sheet}.uniq.sort
    end

    # do a quick pseudo migration.  This should only get executed on the first run
    set_schema do
      primary_key :id
      column :note, :string
      column :start, :timestamp
      column :end, :timestamp
      column :sheet, :string
    end
    create_table unless table_exists?
  end

  class Meta < Sequel::Model(:meta)
    plugin :schema

    set_schema do
      primary_key :id
      column :key, :string
      column :value, :string
    end
    create_table unless table_exists?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
samg-timetrap-0.1.1 lib/timetrap/models.rb
samg-timetrap-0.1.2 lib/timetrap/models.rb
samg-timetrap-1.0.0 lib/timetrap/models.rb
samg-timetrap-1.0.1 lib/timetrap/models.rb
samg-timetrap-1.0.3 lib/timetrap/models.rb
samg-timetrap-1.1.0 lib/timetrap/models.rb