Class Ramaze::Request
In: lib/ramaze/request.rb
Parent: Innate::Request

The purpose of this class is to act as a simple wrapper for Rack::Request and provide some convinient methods for our own use.

Methods

Constants

INTERESTING_HTTP_VARIABLES = (/USER|HOST|REQUEST|REMOTE|FORWARD|REFER|PATH|QUERY|VERSION|KEEP|CACHE/)
REQUEST_STRING_FORMAT = "#<%s params=%p cookies=%p env=%p>"

Public Instance methods

Try to find out which languages the client would like to have and sort them by weight, (most wanted first).

Returns and array of locales from env[‘HTTP_ACCEPT_LANGUAGE]. e.g. ["fi", "en", "ja", "fr", "de", "es", "it", "nl", "sv"]

Usage:

    request.accept_language # => ['en-us', 'en', 'de-at', 'de']

@param [String to_s] string the value of HTTP_ACCEPT_LANGUAGE @return [Array] list of locales @see Request#accept_language_with_weight @author manveru

Transform the HTTP_ACCEPT_LANGUAGE header into an Array with:

    [[lang, weight], [lang, weight], ...]

This algorithm was taken and improved from the locales library.

Usage:

    request.accept_language_with_weight
    # => [["en-us", 1.0], ["en", 0.8], ["de-at", 0.5], ["de", 0.3]]

@param [String to_s] string the value of HTTP_ACCEPT_LANGUAGE @return [Array] array of [lang, weight] arrays @see Request#accept_language @author manveru

Interesting HTTP variables from env

http_vars()

Alias for http_variables

inspect()

Alias for to_s

locales(string = env['HTTP_ACCEPT_LANGUAGE'])

Alias for accept_language

you can access the original @request via this method_missing, first it tries to match your method with any of the HTTP parameters then, in case that fails, it will relay to @request

Pretty prints current action with parameters, cookies and enviroment variables.

Sets any arguments passed as @instance_variables for the current action.

Usage:

    request.params # => {'name' => 'manveru', 'q' => 'google', 'lang' => 'de'}
    request.to_ivs(:name, :q)

    @q    # => 'google'
    @name # => 'manveru'
    @lang # => nil
to_ivs(*args)

[Validate]