Module: JumpBack::Redirection

Defined in:
lib/jump_back/redirect_back.rb,
lib/jump_back/return_to_referer.rb

Instance Method Summary collapse

Instance Method Details

#clear_refererObject



16
17
18
# File 'lib/jump_back/return_to_referer.rb', line 16

def clear_referer
  session.delete(:jump_back_stored_referer)
end

#redirect_back(path = root_path, options = {}) ⇒ Object



9
10
11
12
# File 'lib/jump_back/redirect_back.rb', line 9

def redirect_back(path=root_path, options={})
  parsed_args = OptionsParser.parse(path, options, root_path)
  redirect_to RedirectionDeterminer.new(request, parsed_args[:path], parsed_args[:jump_back_options]).path, parsed_args[:redirect_options]
end

#return_to_referer(path = root_path, options = {}) ⇒ Object



11
12
13
14
# File 'lib/jump_back/return_to_referer.rb', line 11

def return_to_referer(path=root_path, options={})
  parsed_args = OptionsParser.parse(path, options, root_path)
  session[:jump_back_stored_referer] ? redirect_to(clear_referer, parsed_args[:redirect_options]) : redirect_to(parsed_args[:path], parsed_args[:redirect_options])
end

#save_refererObject



7
8
9
# File 'lib/jump_back/return_to_referer.rb', line 7

def save_referer
  session[:jump_back_stored_referer] ||= request.referer
end