README.rdoc in state_machine-0.6.0 vs README.rdoc in state_machine-0.6.1
- old
+ new
@@ -44,10 +44,11 @@
* State predicates
* State-driven instance / class behavior
* State values of any data type
* Dynamically-generated state values
* Inheritance
+* Internationalization
* GraphViz visualization creator
Examples of the usage patterns for some of the above features are shown below.
You can find much more detailed documentation in the actual API.
@@ -222,11 +223,11 @@
A brief overview of these integrations is described below.
=== ActiveRecord
The ActiveRecord integration adds support for database transactions, automatically
-saving the record, named scopes, and observers. For example,
+saving the record, named scopes, validation errors, and observers. For example,
class Vehicle < ActiveRecord::Base
state_machine :initial => :parked do
before_transition any => :idling, :do => :put_on_seatbelt
after_transition any => :parked do |vehicle, transition|
@@ -264,11 +265,11 @@
=== DataMapper
Like the ActiveRecord integration, the DataMapper integration adds support for
database transactions, automatically saving the record, named scopes, Extlib-like
-callbacks, and observers. For example,
+callbacks, validation errors, and observers. For example,
class Vehicle
include DataMapper::Resource
property :id, Serial
@@ -317,12 +318,12 @@
machines, see StateMachine::Integrations::DataMapper.
=== Sequel
Like the ActiveRecord integration, the Sequel integration adds support for
-database transactions, automatically saving the record, named scopes, and
-callbacks. For example,
+database transactions, automatically saving the record, named scopes, validation
+errors and callbacks. For example,
class Vehicle < Sequel::Model
state_machine :initial => :parked do
before_transition any => :idling, :do => :put_on_seatbelt
after_transition any => :parked do |transition|
@@ -344,10 +345,33 @@
end
For more information about the various behaviors added for Sequel state
machines, see StateMachine::Integrations::Sequel.
+== Compatibility
+
+Although state_machine introduces a simplified syntax, it still remains
+backwards compatible with previous versions and other state-related libraries.
+For example, transitions and callbacks can continue to be defined like so:
+
+ class Vehicle
+ state_machine :initial => :parked do
+ before_transition :to => :idling, :do => :put_on_seatbelt
+ after_transition :to => :parked do |transition|
+ self.seatbelt = 'off' # self is the record
+ end
+
+ event :ignite do
+ transition :from => :parked, :to => :idling
+ end
+ end
+ end
+
+Although this verbose syntax will most likely always be supported, it is
+recommended that any state machines eventually migrate to the syntax introduced
+in version 0.6.0.
+
== Tools
=== Generating graphs
This library comes with built-in support for generating di-graphs based on the
@@ -412,9 +436,13 @@
To run the entire test suite (will test ActiveRecord, DataMapper, and Sequel
integrations if the proper dependencies are available):
rake test
+
+Target specific versions of integrations like so:
+
+ rake test AR_VERSION=2.1.0 DM_VERSION=0.9.0 SEQUEL_VERSION=2.8.0
== Dependencies
By default, there are no dependencies. If using specific integrations, those
dependencies are listed below.