Class: Ramaze::Dispatcher::Action

Inherits:
Object
  • Object
show all
Extended by:
Trinity
Defined in:
lib/ramaze/dispatcher/action.rb

Overview

This dispatcher is responsible for relaying requests to Controller::handle and filtering the results using FILTER.

Constant Summary collapse

FILTER =

The response is passed to each filter by sending .call(response) to it.

OrderedSet[
  # Ramaze::Tool::Localize,
]

Class Method Summary collapse

Methods included from StateAccessor

each, #state_accessor, #state_reader, #state_writer

Class Method Details

.call(path) ⇒ Object

Takes path, asks Controller to handle it and builds a response on success. The response is then passed to each member of FILTER for post-processing.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ramaze/dispatcher/action.rb', line 25

def call(path)
  log(path)

  catch(:respond) {
    response.write Controller.handle(path)
  }

  FILTER.each{|f| f.call(response)}
  response
rescue Ramaze::Error => ex
  ex
end

.log(path) ⇒ Object

Logs the request via Log#info unless it’s boring.



40
41
42
43
44
45
46
# File 'lib/ramaze/dispatcher/action.rb', line 40

def log(path)
  case path
  when *Global.boring
  else
    Log.info("Dynamic request from #{request.ip}: #{request.request_uri}")
  end
end