boof / action_sequence
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (3)
- Wiki (1)
- Graphs
-
Tree:
13bb8ad
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
MIT-LICENSE | ||
| |
README.rdoc | Mon Jul 14 00:45:57 -0700 2008 | |
| |
Rakefile | Mon Jul 14 00:45:57 -0700 2008 | |
| |
init.rb | Sun Jul 13 04:06:53 -0700 2008 | |
| |
lib/ | ||
| |
tasks/ | ||
| |
test/ | Mon Jul 14 00:45:57 -0700 2008 |
README.rdoc
ActionSequence
Multipage form routing for controller actions.
This plugin adds simple sequencing functionality to controller actions. ActionSequence does so by tracking a so called walker parameter.
Features
- seperates form routing from controller actions
- easy DSL (ActionSequence::Initializer)
- easy to customize because of it’s simple layout (ActionSequence / ActionSequence::Walker / ActionSequence::Step)
- tested (with test/spec)
Example
class ItemController < ApplicationController
# Initialize item sequence to fetch current index from params[:steps_name]
sequence :item, :steps_name do
enter_stuff do |s|
if params[:back] then s.previous
elsif @item.valid_stuff? then s.next
end
end
select_other_stuff(:meth1, :meth2) do |s|
if params[:back] then s.previous
elsif @item.save then s[:finished]
end
end
end
before_filter :load_item
before_filter :walk_item_sequence, :only => [:create, :update]
# Executed when :select_other_stuff is walked.
def meth1
# does something
end
def meth2
# does something
end
# Walks a specific step, means:
#
# Assigns step to @steps_name and runs required methods,
# but doesn't execute steps decision block!
def new
walk_item_sequence :enter_stuff
end
def edit
walk_item_sequence :enter_stuff
end
# Walk to params[:steps_name]
def create
unless item_sequence.finished_with? @steps_name
render :action => :new
else
redirect_to :action => :list
end
end
def update
unless item_sequence.finished_with? @steps_name
render :action => :edit
else
redirect_to :action => :list
end
end
end
Copyright © 2008 Florian Aßmann, released under the MIT license

