README.md in transitions-0.1.9 vs README.md in transitions-0.1.10
- old
+ new
@@ -1,13 +1,10 @@
### Overview
+[![Build status](https://secure.travis-ci.org/troessner/transitions.png?branch=master)](http://travis-ci.org/troessner/transitions)
+[![Gem Version](https://badge.fury.io/rb/transitions.png)](http://badge.fury.io/rb/transitions)
+[![Code Climate](https://codeclimate.com/github/troessner/transitions.png)](https://codeclimate.com/github/troessner/transitions)
-[<img
-src="https://secure.travis-ci.org/troessner/transitions.png?branch=master"/>](
-http://travis-ci.org/troessner/transitions) [<img
-src="https://badge.fury.io/rb/transitions.png" alt="Gem Version"
-/>](http://badge.fury.io/rb/transitions)
-
### Synopsis
`transitions` is a ruby state machine implementation.
### Compatibility
@@ -69,11 +66,11 @@
**Known limitations:**
* You can only use one state machine per model. While in theory you can
define two or more, this won't work as you would expect. Not supporting
this was intentional, if you're interested in the ratione look up version
- 1.0.0 in the CHANGELOG.
+ 0.1.0 in the CHANGELOG.
* Use symbols, not strings for declaring the state machine. Using strings is
**not** supported as is using whitespace in names (because `transitions`
possibly generates methods out of this).
@@ -108,10 +105,15 @@
In addition, a `can_transition?` method is added to the object that expects one or more event names as arguments. This semi-verbose method name is used to avoid collission with [https://github.com/ryanb/cancan](the authorization gem CanCan).
>> Product.new.can_transition? :out_of_stock
=> true
+If you need to get all available transitions for current state you can simply call:
+
+ >> Product.new.available_transitions
+ => [:discontinued, :out_of_stock]
+
#### 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:
@@ -140,13 +142,19 @@
#### Using `guard`
Each event definition takes an optional `guard` argument, which acts as a
predicate for the transition.
-You can pass in a Symbol, a String, or a Proc like this:
+You can pass in Symbols, Strings, or Procs like this:
event :discontinue do
transitions :to => :discontinued, :from => [:available, :out_of_stock], :guard => :can_discontinue
+ end
+
+or
+
+ event :discontinue do
+ transitions :to => :discontinued, :from => [:available, :out_of_stock], :guard => [:can_discontinue, :super_sure?]
end
Any arguments passed to the event method will be passed on to the `guard`
predicate.