Sha256: 5e42051966a579b29bf95eab1469cba31f62f0a9fa64ad7116cbb43bfdea6cb0

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

class StateMachineModel < ActiveRecord::Base

  if respond_to?(:state_machine)

    state_machine :initial => :state1 do

      state :state1

      state :state2

      state :state3

      event :event do
        transition :state1 => :state2
      end

      event :another_event do
        transition :state1 => :state3
      end

      after_transition :state1 => :state2, :do => :event_callback

    end

    state_machine :custom_state, :initial => :state1 do

      state :state1

      state :state2

      state :state3

      event :event do
        transition :state1 => :state2
      end

      event :another_event do
        transition :state1 => :state3
      end

      after_transition :state1 => :state2, :do => :custom_state_event_callback

    end

    def event_callback
    end

    def custom_state_event_callback
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_candy-0.3.1 spec/shared/app_root/app/models/state_machine_model.rb
rspec_candy-0.3.0 spec/shared/app_root/app/models/state_machine_model.rb