| Class | ActionFlow::ViewStep |
| In: |
lib/action_flow/view_step.rb
|
| Parent: | ActionFlow::FlowStep |
This class allows the controllers to create view steps.
example usage :
view_step :view_name do
on :success => :another_step on :back => :yet_another_step
end
The view name will be stored in the @view_name instance variable until it is needed.
If no method corresponding to @view_name is defined inside the calling controller upon execution, the ViewStep tries to render a file with the same name as the @view_step value. Therefore, it is not mandatory to define view_step methods in the flow controller.
Initializes the instance
# File lib/action_flow/view_step.rb, line 49 def initialize( m_view_name ) # Holds the view name to render once the execution is complete @view_name = m_view_name # Tells the framework that no method definition is required for # this step type @definition_required = false end
This method is required by the ActionFlow::Base and will be called once it relays the execution to this step instance
# File lib/action_flow/view_step.rb, line 65 def execute(*args) # Verify if the controller answers to the @view_name value if args[0].respond_to? @view_name # The controller defines a method with the same name as @view_name. # Kewl! A 'someone else problem' !!! return args[0].send( @view_name ) else # Do we have to do everything here? lazy user... # First, render something args[0].send :render, :action => @view_name # Then, tell the controller to relay execution to the view return ActionFlow::Event.new(:render) end end