Class: ControllerCaller

Inherits:
Rad::Conveyors::Processor show all
Defined in:
lib/rad/controller/processors/controller_caller.rb

Instance Attribute Summary

Attributes inherited from Rad::Conveyors::Processor

#next_processor

Instance Method Summary collapse

Methods inherited from Rad::Conveyors::Processor

#initialize, inspect

Constructor Details

This class inherits a constructor from Rad::Conveyors::Processor

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rad/controller/processors/controller_caller.rb', line 4

def call
  # prepare
  response = workspace.response.must_be.defined
  klass = workspace.class.must_be.present
  raise "The controller class #{klass} must be a Rad::Controller::Abstract!" unless klass.is? Rad::Controller::Abstract
  action_name = workspace.action_name = workspace.method_name
  format = workspace.params.format

  # call
  controller = workspace.controller = klass.new
  controller.set! params: workspace.params, action_name: workspace.action_name
  workspace.content = controller.call action_name
end