class JumpBack::PathFinder

Attributes

path[R]
uri[R]

Public Class Methods

new(request, path, options) click to toggle source
# File lib/jump_back/path_finder.rb, line 6
def initialize(request, path, options)
  @uri = Urls.uri(request.env["HTTP_REFERER"])
  @path = determine_path(request, path, options)
end

Public Instance Methods

has_referer?(request) click to toggle source
# File lib/jump_back/path_finder.rb, line 15
def has_referer?(request)
  !request.env["HTTP_REFERER"].blank? and request.env["HTTP_REFERER"] != request.env["REQUEST_URI"]
end
is_local?(request, options) click to toggle source
# File lib/jump_back/path_finder.rb, line 19
def is_local?(request, options)
  return true if options[:offsite]
  !(host && host != request.host)
end
redirect_back?(request, options) click to toggle source
# File lib/jump_back/path_finder.rb, line 11
def redirect_back?(request, options)
  has_referer?(request) ? is_local?(request, options) ? true : false : false
end

Private Instance Methods

determine_path(request, path, options) click to toggle source
# File lib/jump_back/path_finder.rb, line 28
def determine_path(request, path, options)
  redirect_back?(request, options) ? :back : path
end
host() click to toggle source
# File lib/jump_back/path_finder.rb, line 32
def host
  uri.host if uri
end