Class: Utopia::Redirection::Rewrite

Inherits:
ClientRedirect show all
Defined in:
lib/utopia/redirection.rb

Overview

Rewrite requests that match the given pattern to a single destination.

Instance Attribute Summary

Attributes inherited from ClientRedirect

#max_age, #status

Instance Method Summary collapse

Methods inherited from ClientRedirect

#cache_control, #call, #freeze, #headers, #redirect

Constructor Details

#initialize(app, patterns, status: 301) ⇒ Rewrite

Returns a new instance of Rewrite



150
151
152
153
154
# File 'lib/utopia/redirection.rb', line 150

def initialize(app, patterns, status: 301)
	@patterns = patterns
	
	super(app, status: status)
end

Instance Method Details

#[](path) ⇒ Object



156
157
158
159
160
# File 'lib/utopia/redirection.rb', line 156

def [] path
	if location = @patterns[path]
		return redirect(location)
	end
end