Sha256: 64e026f4e580b026f01934aeddd86ee80a6b5071064a43ab988a2510f08c83f2

Contents?: true

Size: 483 Bytes

Versions: 35

Compression:

Stored size: 483 Bytes

Contents

require 'active_record'
class Transactor < ActiveRecord::Base

  belongs_to :worker

  include AASM
  aasm :column => :status do
    state :sleeping, :initial => true
    state :running, :before_enter => :start_worker, :after_enter => :fail

    event :run do
      transitions :to => :running, :from => :sleeping
    end
  end

private

  def start_worker
    worker.update_attribute(:status, 'running')
  end

  def fail
    raise StandardError.new('failed on purpose')
  end

end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
aasm-4.2.0 spec/models/transactor.rb
aasm-4.1.1 spec/models/transactor.rb
aasm-4.1.0 spec/models/transactor.rb
aasm-4.0.8 spec/models/transactor.rb
aasm-4.0.7 spec/models/transactor.rb
aasm-4.0.6 spec/models/transactor.rb
aasm-4.0.5 spec/models/transactor.rb
aasm-4.0.4 spec/models/transactor.rb
aasm-4.0.3 spec/models/transactor.rb
aasm-4.0.2 spec/models/transactor.rb
aasm-4.0.1 spec/models/transactor.rb
aasm-4.0.0 spec/models/transactor.rb
aasm-3.4.0 spec/models/transactor.rb
aasm-3.3.3 spec/models/transactor.rb
aasm-3.3.2 spec/models/transactor.rb
aasm-3.3.1 spec/models/transactor.rb
aasm-3.3.0 spec/models/transactor.rb
aasm-3.2.1 spec/models/transactor.rb
aasm-3.2.0 spec/models/transactor.rb
aasm-3.1.1 spec/models/transactor.rb