Module: Adva::Responder::Redirect

Included in:
Base
Defined in:
lib/adva/responder/redirect.rb

Instance Method Summary collapse

Instance Method Details

#controller_action_pathObject



26
27
28
# File 'lib/adva/responder/redirect.rb', line 26

def controller_action_path
  "#{controller_path}##{params[:action]}"
end

#current_redirectObject



21
22
23
24
# File 'lib/adva/responder/redirect.rb', line 21

def current_redirect
  target = Registry.get(:redirect, controller_action_path)
  target.respond_to?(:call) ? target.call(controller) : target
end

#registry_redirectObject



15
16
17
18
19
# File 'lib/adva/responder/redirect.rb', line 15

def registry_redirect
  if !has_errors? && target = current_redirect
    redirect_to(target)
  end
end

#return_to_redirectObject



11
12
13
# File 'lib/adva/responder/redirect.rb', line 11

def return_to_redirect
  redirect_to(params[:return_to]) if !get? && params[:return_to] && !has_errors?
end

#to_htmlObject



7
8
9
# File 'lib/adva/responder/redirect.rb', line 7

def to_html
  return_to_redirect || registry_redirect || super
end