Class: ActionDispatch::Routing::OptionRedirect

Inherits:
Redirect
  • Object
show all
Defined in:
lib/action_dispatch/routing/redirection.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Redirect

#block, #status

Instance Method Summary collapse

Methods inherited from Redirect

#call, #initialize

Constructor Details

This class inherits a constructor from ActionDispatch::Routing::Redirect

Instance Method Details

#inspectObject



101
102
103
# File 'lib/action_dispatch/routing/redirection.rb', line 101

def inspect
  "redirect(#{status}, #{options.map{ |k,v| "#{k}: #{v}" }.join(', ')})"
end

#path(params, request) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/action_dispatch/routing/redirection.rb', line 80

def path(params, request)
  url_options = {
    :protocol => request.protocol,
    :host     => request.host,
    :port     => request.optional_port,
    :path     => request.path,
    :params   => request.query_parameters
  }.merge! options

  if !params.empty? && url_options[:path].match(/%\{\w*\}/)
    url_options[:path] = (url_options[:path] % escape_path(params))
  end

  if relative_path?(url_options[:path])
    url_options[:path] = "/#{url_options[:path]}"
    url_options[:script_name] = request.script_name
  end

  ActionDispatch::Http::URL.url_for url_options
end