Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document parameters in readme #722

Merged
merged 2 commits into from Oct 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions README.md
Expand Up @@ -212,15 +212,28 @@ 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 state machine will attempt to transition to that state. To avoid any ambiguity, we recommend using keyword
args like so:

```ruby
job = Job.new
job.run(process: :defragmentation)
```
In this case `set_process` would be called with the argument `{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.

Expand Down