documented parameterised events

This commit is contained in:
Vladimir Meremyanin 2013-02-02 11:10:45 +04:00 committed by Thorsten Böttger
parent ac5f9c851b
commit a536d77b92
1 changed files with 14 additions and 1 deletions

View File

@ -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