democracyworks / hat-trick

Hat Trick - Rails wizards done right
MIT License
5 stars 0 forks source link

Methods to detect step sequence #23

Open paulschreiber opened 12 years ago

paulschreiber commented 12 years ago

It would be nice to have methods to detect step sequence. Something like step_is_after?(:step) and step_is_before?(:step).

This way, I could try up all the step checking blocks

before do |voter|
  redirect_to_step :address unless voter.state
end

i.e.

before :each do
  if step_is_before?(:check_registration)
    redirect_to_step :start unless voter.email
  else
    redirect_to_step :address unless voter.state
  end
end
cap10morgan commented 12 years ago

Those methods exist already. I'll document them when I prepare the 0.1.3 release of hat-trick.

paulschreiber commented 12 years ago

I see steps_before_current. Are you suggesting step_is_after?(:step) == steps_before_current.include?(:step) ?

Is there a good method for getting the current step? Should before :each do take a block argument, i.e. before :each do |step|?