module StateBoss

Constants

VERSION

Attributes

_state[R]

Public Class Methods

included(klass) click to toggle source
# File lib/state_boss.rb, line 10
def self.included(klass)
  klass.extend ClassMethods
  klass.prepend Initializer

  klass.class_eval do
    @default_state = nil
    @events = {}
    @transitions = {}
  end
end

Public Instance Methods

current_state() click to toggle source
# File lib/state_boss.rb, line 21
def current_state
  _state
end
finished_state?() click to toggle source
# File lib/state_boss.rb, line 30
def finished_state?
  next_states.nil?
end
next_states() click to toggle source
# File lib/state_boss.rb, line 25
def next_states
  transitions = self.class.instance_variable_get(:@transitions)
  transitions[_state][:to]
end

Private Instance Methods

ready?() click to toggle source
# File lib/state_boss.rb, line 38
def ready?
  !_state.nil?
end