README.rdoc in transitions-0.0.16 vs README.rdoc in transitions-0.0.17
- old
+ new
@@ -2,11 +2,11 @@
{<img src="https://secure.travis-ci.org/troessner/transitions.png"/>}[http://travis-ci.org/troessner/transitions]
= Synopsis
-`transitions` is a ruby state machine implementation.
+<tt>transitions</tt> is a ruby state machine implementation.
= Installation
== Rails
@@ -49,17 +49,16 @@
= Features
== Events
When you declare an event, say <tt>discontinue</tt>, two methods are declared for
-you: <tt>discontinue</tt> and <tt>discontinue!</tt>. Both events will call
-<tt>write_state_without_persistence</tt> on successful transition, but only the
-bang(!)-version will call <tt>write_state</tt>.
+you: <tt>discontinue</tt> and <tt>discontinue!</tt>. Both events will modify the <tt>state</tt> attribute on successful transition,
+but only the bang(!)-version will call <tt>save!</tt>.
== Automatic scope generation
-`transitions` will automatically generate scopes for you if you are using ActiveRecord and tell it to do so via the `auto_scopes` option:
+<tt>transitions</tt> will automatically generate scopes for you if you are using ActiveRecord and tell it to do so via the <tt>auto_scopes</tt> option:
Given a model like this:
class Order < ActiveRecord::Base
include ActiveModel::Transitions
@@ -76,22 +75,22 @@
>> Order.create!
=> #<Order id: 3, state: "pick_line_items", description: nil, created_at: "2011-08-23 15:48:46", updated_at: "2011-08-23 15:48:46">
>> Order.pick_line_items
=> [#<Order id: 3, state: "pick_line_items", description: nil, created_at: "2011-08-23 15:48:46", updated_at: "2011-08-23 15:48:46">]
-== Using `on_transition`
+== Using <tt>on_transition</tt>
Each event definition takes an optional "on_transition" argument, which allows you to execute methods on transition.
You can pass in a Symbol, a String, a Proc or an Array containing method names as Symbol or String like this:
event :discontinue do
transitions :to => :discontinued, :from => [:available, :out_of_stock], :on_transition => [:do_discontinue, :notify_clerk]
end
-== Using `success`
+== Using <tt>success</tt>
-In case you need to trigger a method call after a successful transition you can use `success`:
+In case you need to trigger a method call after a successful transition you can use <tt>success</tt>:
event :discontinue, :success => :notfiy_admin do
transitions :to => :discontinued, :from => [:available, :out_of_stock]
end
@@ -122,10 +121,10 @@
== Listing all the available states
You can easily get a listing of all available states:
- Order.available_states # Uses the `default` state machine
+ Order.available_states # Uses the <tt>default</tt> state machine
# => [:pick_line_items, :picking_line_items]
In case you have multiple state machines you can also pass the state machine name:
Order.available_states(:your_machine)