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:
parent
5e0341c986
commit
44cb4c2039
2 changed files with 16 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
|||
# 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
|
||||
|
||||
|
|
14
README.md
14
README.md
|
@ -248,6 +248,20 @@ If you want to provide guards for all transitions within an event, you can use e
|
|||
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
|
||||
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue