pluginaweek / state_machine

Adds support for creating state machines for attributes on any Ruby class
http://www.pluginaweek.org
MIT License
3.74k stars 510 forks source link

Passing Transition args to callbacks #193

Open the8472 opened 12 years ago

the8472 commented 12 years ago

To get the perform parameters of Model.some_transition.perform(:a, :b, {:c => :d}) we currently have to do something like

before_transition :on => :some_transition do |model, transition|
  (a,b,opts) = transition.args
  # actual code here
end

It would be nice to make the syntax a bit more compact by passing the perform arguments to the callbacks directly if their arity allows

it should look like this

before_transition :on => :some_transition do |model, transition, a, b, opts|
   # actual code here
end

The same applies to method callbacks instead of procs of course.

rngtng commented 12 years ago

yeah, +1

obrie commented 11 years ago

There are some complexities with around callbacks and some of the ORM integrations for this. I'll think about this as part of the 2.0.0 release.

mark-ellul commented 11 years ago

removed previous question as I did not see mailing list. Thanks for such a great gem!