class Flatrack::Redirector::Redirect

Attributes

type[R]
url[R]

Public Class Methods

new(url, type = :permanent) click to toggle source
# File lib/flatrack/redirector.rb, line 38
def initialize(url, type = :permanent)
  @url, @type = url, type
  code # just to check args
end

Public Instance Methods

code() click to toggle source

Returns the code for the specified type @returns [Fixnum]

# File lib/flatrack/redirector.rb, line 45
def code
  case type.to_sym
  when :permanent
    301
  when :temporary
    302
  else
    raise ArgumentError, 'type must be :temporary or :permanent'
  end
end
response() click to toggle source
# File lib/flatrack/redirector.rb, line 56
def response
  [code, { 'location' => url }, ["you are being redirected to: `#{url}`"]]
end