1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

support if and unless guard syntax (extended README)

This commit is contained in:
Thorsten Böttger 2014-11-14 18:08:34 +01:00
parent 5e0341c986
commit 44cb4c2039
2 changed files with 16 additions and 2 deletions

View file

@ -1,8 +1,8 @@
# CHANGELOG # CHANGELOG
## 3.9.0 (not yet released) ## 3.5.0 (not yet released)
* deprecated old aasm_* class methods (old-style DSL), in preparation for AASM v4.0.0 * support `if` and `unless` guard syntax: (see [issue #179](https://github.com/aasm/aasm/issues/179) and [issue #181](https://github.com/aasm/aasm/issues/181)), thanks to [@bigtunacan](https://github.com/bigtunacan)
## 3.4.0 ## 3.4.0

View file

@ -248,6 +248,20 @@ If you want to provide guards for all transitions within an event, you can use e
end end
``` ```
If you prefer a more Ruby-like guard syntax, you can use `if` and `unless` as well:
```ruby
event :clean do
transitions :from => :running, :to => :cleaning, :unless => :cleaning_needed?
end
event :sleep do
transitions :from => :running, :to => :sleeping, :if => :cleaning_needed?
end
end
```
### Transitions ### Transitions
In the event of having multiple transitions for an event, the first transition that successfully completes will stop other transitions in the same event from being processed. In the event of having multiple transitions for an event, the first transition that successfully completes will stop other transitions in the same event from being processed.