Skip to content

Commit

Permalink
Various improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Sep 3, 2008
1 parent 7aae872 commit 2ac6955
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/auto_redirection/controller_extensions.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def redirection_parameter_for_current_request
return redirection_information_for_current_request.marshal return redirection_information_for_current_request.marshal
end end


def clear_redirection_information
# TODO: document and test this
@_redirection_information_given = true
@_redirection_information = nil
end

# The current request may contain redirection information. # The current request may contain redirection information.
# If auto-redirection information is given, then this method will redirect # If auto-redirection information is given, then this method will redirect
# the HTTP client to that location (by calling +redirect_to+) and return true. # the HTTP client to that location (by calling +redirect_to+) and return true.
Expand Down
6 changes: 6 additions & 0 deletions lib/auto_redirection/redirection_information.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ def marshal(encrypt = true, ascii7 = true)
end end
end end


def inspect
return sprintf("#<%s:0x%x @controller=%s @action=%s @method=%s\n" <<
"@params=%s>", self.class, object_id, controller.inspect,
action.inspect, method.inspect, params.inspect)
end

def ==(other) def ==(other)
return other.is_a?(ControllerRedirectionInformation) && return other.is_a?(ControllerRedirectionInformation) &&
other.controller == controller && other.controller == controller &&
Expand Down
9 changes: 8 additions & 1 deletion lib/auto_redirection/view_helpers.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ module ViewHelpers
def pass_redirection_information def pass_redirection_information
return render_redirection_information(get_redirection_information) return render_redirection_information(get_redirection_information)
end end

def save_redirection_information
# TODO: document and test this
return render_redirection_information(controller.send(:redirection_information_for_current_request))
end


private private
def get_redirection_information def get_redirection_information
Expand All @@ -48,7 +53,9 @@ def render_redirection_information(info)
html << ">" html << ">"
if AutoRedirection.debug? if AutoRedirection.debug?
# Value intentionally not escaped. # Value intentionally not escaped.
html << "\n<!-- #{info.inspect} -->" debug_info = info.inspect
debug_info.gsub!('--', '~~')
html << "\n<!-- #{debug_info} -->"
end end
return html return html
else else
Expand Down

0 comments on commit 2ac6955

Please sign in to comment.