class Utopia::Redirection::Moved
Rewrite
requests that match the given pattern to a new prefix.
Public Class Methods
new(app, pattern, prefix, status: 301, flatten: false)
click to toggle source
Calls superclass method
Utopia::Redirection::ClientRedirect::new
# File lib/utopia/redirection.rb, line 165 def initialize(app, pattern, prefix, status: 301, flatten: false) @app = app @pattern = pattern @prefix = prefix @flatten = flatten super(app, status: status) end
Public Instance Methods
[](path)
click to toggle source
# File lib/utopia/redirection.rb, line 175 def [] path if path.start_with?(@pattern) if @flatten return redirect(@prefix) else return redirect(path.sub(@pattern, @prefix)) end end end