From a536d77b92bfbaa5a8be1370500050bd65359999 Mon Sep 17 00:00:00 2001 From: Vladimir Meremyanin Date: Sat, 2 Feb 2013 11:10:45 +0400 Subject: [PATCH] documented parameterised events --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ecf6cb..e31320d 100644 --- a/README.md +++ b/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