Sha256: 6b500e9aa9eea53c668637be278ada4e1231a09de5bd965244a29ceadf3a64a3

Contents?: true

Size: 654 Bytes

Versions: 5

Compression:

Stored size: 654 Bytes

Contents

class Review < ActiveRecord::Base
  include StateShifter::Definition

  state_machine do

    # first state to be defined is the initial one
    state :new do
      tags :reviewable
      event :submit => :awaiting_review
    end

    state :awaiting_review do
      tags :reviewable, :processing
      event :review => :being_reviewed
    end

    state :being_reviewed do
      tags :reviewable, :processing
      event :accept => :accepted, :if => :cool_article?
      event :reject => :rejected, :if => :bad_article?
    end

    state :accepted
    state :rejected

  end

  def cool_article?
    true
  end

  def bad_article?
    false
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
state_shifter-1.1.3 examples/review.rb
state_shifter-1.1.2 examples/review.rb
state_shifter-1.0.7 examples/review.rb
state_shifter-1.0.5 examples/review.rb
state_shifter-1.0.3 examples/review.rb