Sha256: 85fee0f0ecda987b74397b2ec3a877f3550068c4c9a8bfdca692cbb5a23efeec

Contents?: true

Size: 539 Bytes

Versions: 10

Compression:

Stored size: 539 Bytes

Contents

class Simple
  include StateShifter::Definition

  state_machine do 

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

    state :awaiting_review do
      event :review => :being_reviewed
    end

    state :being_reviewed do
      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

10 entries across 10 versions & 1 rubygems

Version Path
state_shifter-1.1.3 examples/simple.rb
state_shifter-1.1.2 examples/simple.rb
state_shifter-1.0.7 examples/simple.rb
state_shifter-1.0.5 examples/simple.rb
state_shifter-1.0.3 examples/simple.rb
state_shifter-0.8.1 examples/simple.rb
state_shifter-0.8.0 examples/simple.rb
state_shifter-0.7.2 examples/simple.rb
state_shifter-0.7.1 examples/simple.rb
state_shifter-0.7.0 examples/simple.rb