StateMachine Gem

state_machine gem adds support for creating state machines for attributes on any Ruby class. It introduces the various parts of a real state machine, including states, events, transitions, and callbacks

Represents a state machine for a particular attribute. State machines consist of states, events and a set of transitions that define how the state changes after a particular event is fired.

A state machine will not know all of the possible states for an object unless they are referenced somewhere in the state machine definition. As a result, any unused states should be defined with the other_states or state helper.

Features

  • Initial states
  • Multiple states on a single class
  • Namespaced states
  • Conditional transitions: before/after/around/failure transition hooks with explicit transition requirements
  • Transition callbacks
  • State predicates
  • State-driven instance/class behavior
  • State values of any data type
  • Dynamically-generated state values
  • Attribute-based event transitions
  • Parallel events
  • Path analysis
  • Inheritance
  • GraphViz visualization creator
  • Flexible syntax
  • Customized state values
  • Integration with ActiveModel, ActiveRecord, DataMapper, Mongoid, MongoMapper, and Sequel
  • Internationalization

StateMachine::Integrations::ActiveRecord adds support for

  • database transactions
  • automatically saving the record
  • named scopes
  • validation errors
  • observers

results matching ""

    No results matching ""