1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

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

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