Sha256: 6758432b72b377aac6617e4f2fa62c56449f3ba7b820b0f6adbe4f42b82ebb70

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

class App < ActiveRecord::Base
  has_many :logs

  def log which, overwrite = false
    self.gui = which if (overwrite and gui?(which) ) || gui?('')
    save!
  end

  def gui? which = ''
    match = (self.gui == which)
    match
  end

  def unlock
    self.gui = ''
    self.save!
  end

  def interval= intvl
    write_attribute(:interval, intvl*60)
  end

  class << self
    def migrate which = :up
      ActiveRecord::Schema.define do
        if which == :up
          create_table :apps do |t|
            t.integer :pid
            t.string  :gui,      :default => ''
            t.float   :interval, :default => 15.0*60
          end
          App.create!(:gui => '', :interval => 15.0)
        elsif which == :down
          drop_table :apps
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
Pratt-1.6.8-x86-linux models/app.rb
Pratt-1.6.8 models/app.rb
Pratt-1.6.5 models/app.rb
Pratt-1.6.4 models/app.rb