Sha256: e99b5076284e9b54418f19eb827a2c432e5f08e172ddf286138a6d468274d2ca

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

module Ramaze
  module Dispatcher

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

    class Action

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

      FILTER = OrderedSet.new(
        # Ramaze::Tool::Localize,
      ) unless defined?(FILTER)

      class << self
        include Trinity

        # 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.

        def process(path)
          Inform.info("Dynamic request from #{request.ip}: #{request.request_uri}")
          body = Controller.handle(path)
          response = Response.current.build(body)
          FILTER.inject(response){|r,f| f.call(r) }
        rescue Ramaze::Error => ex
          ex
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.3.5 lib/ramaze/dispatcher/action.rb
ramaze-0.3.0 lib/ramaze/dispatcher/action.rb