class ActionDispatch::Routing::PathRedirect - actionpack-4.2.4 Documentation

# class ActionDispatch::Routing::PathRedirect

### Constants

URL_PARTS

### Public Instance Methods

inspect() click to toggle source

    # File lib/action_dispatch/routing/redirection.rb, line 92
    def inspect
      "redirect(#{status}, #{block})"
    end

path(params, request) click to toggle source

    # File lib/action_dispatch/routing/redirection.rb, line 80
    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

### Private Instance Methods

interpolation_required?(string, params) click to toggle source

    # File lib/action_dispatch/routing/redirection.rb, line 97
    def interpolation_required?(string, params)
      !params.empty? && string && string.match(/%\{\w*\}/)
    end