Class: Crystal::Processors::ControllerCaller
- Inherits:
-
Crystal::Processor
- Object
- Crystal::Processor
- Crystal::Processors::ControllerCaller
- Defined in:
- lib/crystal/controller/processors/controller_caller.rb
Instance Attribute Summary collapse
-
#result_variable ⇒ Object
Returns the value of attribute result_variable.
Attributes inherited from Crystal::Processor
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(next_processor, result_variable = 'content') ⇒ ControllerCaller
constructor
A new instance of ControllerCaller.
Methods inherited from Crystal::Processor
Constructor Details
#initialize(next_processor, result_variable = 'content') ⇒ ControllerCaller
Returns a new instance of ControllerCaller.
6 7 8 9 10 11 |
# File 'lib/crystal/controller/processors/controller_caller.rb', line 6 def initialize next_processor, result_variable = 'content' result_variable.must_be.present super(next_processor) @result_variable = result_variable end |
Instance Attribute Details
#result_variable ⇒ Object
Returns the value of attribute result_variable.
4 5 6 |
# File 'lib/crystal/controller/processors/controller_caller.rb', line 4 def result_variable @result_variable end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/crystal/controller/processors/controller_caller.rb', line 13 def call # prepare klass = workspace.class.must_be.present raise "The controller class #{klass} must be a Crystal::AbstractController!" unless klass.is? Crystal::AbstractController controller = workspace.controller = klass.new action = workspace.action = workspace.method_name format = workspace.params.format # call special_result = catch :special_result do controller.run_callbacks :action, :method => action do # call controller controller.send action # render view workspace[result_variable] = controller.render_action :action => action end end if special_result workspace[result_variable] = special_result else workspace[result_variable].must_be.defined end end |