Permalink
Browse files

Document the new transition decorators

  • Loading branch information...
1 parent 1c31f70 commit 3730a4031eb9d942161362f0d2237d4c4131573d @kyleconroy committed Apr 26, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 README.md
View
@@ -78,6 +78,29 @@ Initiate the transition by calling `cycle`
'GO GO GO'
```
+If you only care about where you're coming from (or where you're going), use the `transition_from` and `transition_to` decorator
+
+```python
+import statemachine
+
+class TrafficLight(statemachine.Machine):
+ initial_state = 'red'
+
+ @statemachine.event
+ def cycle(self):
+ yield 'red', 'green'
+ yield 'green', 'yellow'
+ yield 'yellow', 'red'
+
+ @transition_to('yellow')
+ def safety(self):
+ print "SLOW DOWN"
+
+ @transition_from('red')
+ def announce(self):
+ print "GO GO GO"
+```
+
## Installation
$ pip install statemachine

0 comments on commit 3730a40

Please sign in to comment.