Sha256: df0ebe9af85b9d2f1b1b17a1ed47d1808362638704fb65a48d281157804730dc

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

Contents

db = Sequel::DATABASES.first || Sequel.connect(SEQUEL_DB)

[:silent_persistors, :multiple_silent_persistors].each do |t|
  db.create_table(t) do
    primary_key :id
    String "name"
    String "status"
  end
end

module Sequel
  class SilentPersistor < Sequel::Model(:silent_persistors)
    plugin :validation_helpers

    include AASM
    aasm :column => :status, :whiny_persistence => false do
      state :sleeping, :initial => true
      state :running
      event :run do
        transitions :to => :running, :from => :sleeping
      end
      event :sleep do
        transitions :to => :sleeping, :from => :running
      end
    end
    def validate
      validates_presence :name
    end
  end

  class MultipleSilentPersistor< Sequel::Model(:multiple_silent_persistors)
    plugin :validation_helpers

    include AASM
    aasm :left, :column => :status, :whiny_persistence => false do
      state :sleeping, :initial => true
      state :running
      event :run do
        transitions :to => :running, :from => :sleeping
      end
      event :sleep do
        transitions :to => :sleeping, :from => :running
      end
    end

    def validate
      validates_presence :name
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aasm-5.3.1 spec/models/sequel/silent_persistor.rb
aasm-5.3.0 spec/models/sequel/silent_persistor.rb
aasm-5.2.0 spec/models/sequel/silent_persistor.rb
aasm-5.1.1 spec/models/sequel/silent_persistor.rb
aasm-5.1.0 spec/models/sequel/silent_persistor.rb
aasm-5.0.8 spec/models/sequel/silent_persistor.rb
aasm-5.0.7 spec/models/sequel/silent_persistor.rb
aasm-5.0.6 spec/models/sequel/silent_persistor.rb
aasm-5.0.5 spec/models/sequel/silent_persistor.rb
aasm-5.0.4 spec/models/sequel/silent_persistor.rb
aasm-5.0.3 spec/models/sequel/silent_persistor.rb
aasm-5.0.2 spec/models/sequel/silent_persistor.rb
aasm-5.0.1 spec/models/sequel/silent_persistor.rb
aasm-5.0.0 spec/models/sequel/silent_persistor.rb
aasm-4.12.3 spec/models/sequel/silent_persistor.rb
aasm-4.12.2 spec/models/sequel/silent_persistor.rb
aasm-4.12.1 spec/models/sequel/silent_persistor.rb