mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Add documentation about magical parameters
This commit is contained in:
parent
8560d40896
commit
a3fbbcdae6
1 changed files with 13 additions and 2 deletions
15
README.md
15
README.md
|
@ -212,15 +212,26 @@ class LogRunTime
|
|||
end
|
||||
```
|
||||
|
||||
Also, you can pass parameters to events:
|
||||
#### Parameters
|
||||
You can pass parameters to events:
|
||||
|
||||
```ruby
|
||||
job = Job.new
|
||||
job.run(:defragmentation)
|
||||
```
|
||||
|
||||
In this case the `set_process` would be called with `:defragmentation` argument.
|
||||
All guards and after callbacks will receive these parameters. In this case `set_process` would be called with
|
||||
`:defragmentation` argument.
|
||||
|
||||
If the first argument to the event is a state (e.g. `:running` or `:finished`), the argument is consumed and
|
||||
the statemachine will attempt to transition to that state. To avoid any ambiguity use keyword args.
|
||||
|
||||
```ruby
|
||||
job = Job.new
|
||||
job.run(process: :defragmentation)
|
||||
```
|
||||
|
||||
#### Error Handeling
|
||||
In case of an error during the event processing the error is rescued and passed to `:error`
|
||||
callback, which can handle it or re-raise it for further propagation.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue