Class: ActionDispatch::Routing::PathRedirect

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

Constant Summary collapse

URL_PARTS =
/\A([^?]+)?(\?[^#]+)?(#.+)?\z/

Instance Attribute Summary

Attributes inherited from Redirect

#block, #status

Instance Method Summary collapse

Methods inherited from Redirect

#build_response, #call, #initialize, #redirect?

Methods inherited from Endpoint

#app, #dispatcher?, #engine?, #matches?, #rack_app, #redirect?

Constructor Details

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

Instance Method Details

#inspectObject



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

def inspect
  "redirect(#{status}, #{block})"
end

#path(params, request) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
# File 'actionpack/lib/action_dispatch/routing/redirection.rb', line 90

def path(params, request)
  if block.match(URL_PARTS)
    path     = interpolation_required?($1, params) ? $1 % escape_path(params)     : $1
    query    = interpolation_required?($2, params) ? $2 % escape(params)          : $2
    fragment = interpolation_required?($3, params) ? $3 % escape_fragment(params) : $3

    "#{path}#{query}#{fragment}"
  else
    interpolation_required?(block, params) ? block % escape(params) : block
  end
end