mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
documented parameterised events
This commit is contained in:
parent
ac5f9c851b
commit
a536d77b92
1 changed files with 14 additions and 1 deletions
15
README.md
15
README.md
|
@ -81,7 +81,7 @@ class Job
|
|||
state :running
|
||||
|
||||
event :run, :after => :notify_somebody do
|
||||
transitions :from => :sleeping, :to => :running
|
||||
transitions :from => :sleeping, :to => :running, :on_transition => Proc.new {|obj, *args| obj.set_process(*args) }
|
||||
end
|
||||
|
||||
event :sleep do
|
||||
|
@ -89,6 +89,10 @@ class Job
|
|||
end
|
||||
end
|
||||
|
||||
def set_process(name)
|
||||
...
|
||||
end
|
||||
|
||||
def do_something
|
||||
...
|
||||
end
|
||||
|
@ -116,6 +120,15 @@ Here you can see a list of all possible callbacks, together with their order of
|
|||
event:after
|
||||
```
|
||||
|
||||
Also, you can pass parameters to events:
|
||||
|
||||
```ruby
|
||||
job = Job.new
|
||||
job.run(:running, :defragmentation)
|
||||
```
|
||||
|
||||
In this case the set_process would be called with `:defagmentation` argument.
|
||||
|
||||
### Guards
|
||||
|
||||
Let's assume you want to allow particular transitions only if a defined condition is
|
||||
|
|
Loading…
Reference in a new issue