Module: ActionFlow
- Included in:
- ActionController::Base
- Defined in:
- lib/action_flow.rb
Defined Under Namespace
Modules: Helper Classes: Context
Instance Method Summary collapse
Instance Method Details
#flow(name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/action_flow.rb', line 6 def flow(name) helper ActionFlow::Helper flow = "#{name}_flow_context".camelize.constantize define_method(:context) do @context ||= flow.find_or_create(params.delete(:k)) end private :context flow.states.each do |state| define_method(state) do context.at_state(state) context.data.each do |key, value| instance_variable_set("@#{key}", value) end end end define_method(:next) do context.at_state(params.delete(:state)) context.fire_transition(self) redirect_to(:action => context.state, :k => context.key) end end |