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.



133
134
135
136
137
# File 'lib/utopia/redirection.rb', line 133

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

Instance Method Details

#[](path) ⇒ Object



139
140
141
142
143
# File 'lib/utopia/redirection.rb', line 139

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