Method: Merb::AbstractController#_dispatch
- Defined in:
- lib/merb-core/controller/abstract_controller.rb
#_dispatch(action) ⇒ Object
This will dispatch the request, calling internal before/after dispatch callbacks.
If the return value of _call_filters is not :filter_chain_completed the action is not called, and the return from the filters is used instead.
Parameters
- action<~to_s>
-
The action to dispatch to. This will be #send’ed in _call_action. Defaults to :to_s.
Returns
- <~to_s>
-
Returns the string that was returned from the action.
Raises
- ArgumentError
-
Invalid result caught from before filters.
:api: plugin
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/merb-core/controller/abstract_controller.rb', line 277 def _dispatch(action) self.action_name = action self._before_dispatch_callbacks.each { |cb| cb.call(self) } caught = catch(:halt) do start = Time.now result = _call_filters(_before_filters) @_benchmarks[:before_filters_time] = Time.now - start if _before_filters result end @body = case caught when :filter_chain_completed then _call_action(action_name) when String then caught # return *something* if you throw halt with nothing when nil then "<html><body><h1>Filter Chain Halted!</h1></body></html>" when Symbol then __send__(caught) when Proc then self.instance_eval(&caught) else raise ArgumentError, "Threw :halt, #{caught}. Expected String, nil, Symbol, Proc." end start = Time.now _call_filters(_after_filters) @_benchmarks[:after_filters_time] = Time.now - start if _after_filters self._after_dispatch_callbacks.each { |cb| cb.call(self) } @body end |