class Response::Redirect
Abstract redirect response
Public Class Methods
build(location)
click to toggle source
Build redirect response
@param [String] location
the location to redirect to
@return [Response::Redirect]
@example
# 302 response response = Response::Redirect::Found.build('http://example.com') response.status # => 302 response.headers # => { "Location" => "http://example.com", "Content-Type" => "text/plain" } response.body # => "You are beeing redirected to: http://example.com" # 301 response response = Response::Redirect::Permanent.build('http://example.com') response.status # => 301 response.headers # => { "Location" => "http://example.com", "Content-Type" => "text/plain" } response.body # => "You are beeing redirected to: http://example.com" # Overriding defaults response = Response::Redirect::Found.build('http://example.com') do |response| response.with_body("Redirection") end response[2] # => "Redirection"
@api public
Calls superclass method
# File lib/response/redirect.rb, line 37 def self.build(location) super( self::STATUS, { 'Location' => location, 'Content-Type' => TEXT_PLAIN }, "You are beeing redirected to: #{location}" ) end