Class: JumpBack::PathFinder
- Inherits:
-
Object
- Object
- JumpBack::PathFinder
- Defined in:
- lib/jump_back/path_finder.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #has_referer?(request) ⇒ Boolean
-
#initialize(request, path, options) ⇒ PathFinder
constructor
A new instance of PathFinder.
- #is_local?(request, options) ⇒ Boolean
- #redirect_back?(request, options) ⇒ Boolean
Constructor Details
#initialize(request, path, options) ⇒ PathFinder
Returns a new instance of PathFinder.
6 7 8 9 |
# File 'lib/jump_back/path_finder.rb', line 6 def initialize(request, path, ) @uri = Urls.uri(request.env["HTTP_REFERER"]) @path = determine_path(request, path, ) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/jump_back/path_finder.rb', line 4 def path @path end |
Instance Method Details
#has_referer?(request) ⇒ Boolean
15 16 17 |
# 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) ⇒ Boolean
19 20 21 22 |
# File 'lib/jump_back/path_finder.rb', line 19 def is_local?(request, ) return true if [:offsite] !(host && host != request.host) end |
#redirect_back?(request, options) ⇒ Boolean
11 12 13 |
# File 'lib/jump_back/path_finder.rb', line 11 def redirect_back?(request, ) has_referer?(request) ? is_local?(request, ) ? true : false : false end |