Class: Utopia::Redirection::DirectoryIndex
- Inherits:
-
ClientRedirect
- Object
- ClientRedirect
- Utopia::Redirection::DirectoryIndex
- Defined in:
- lib/utopia/redirection.rb
Overview
Redirect urls that end with a ‘/`, e.g. directories.
Instance Attribute Summary
Attributes inherited from ClientRedirect
Instance Method Summary collapse
- #[](path) ⇒ Object
-
#initialize(app, index: 'index') ⇒ DirectoryIndex
constructor
A new instance of DirectoryIndex.
Methods inherited from ClientRedirect
#cache_control, #call, #freeze, #headers, #redirect
Constructor Details
#initialize(app, index: 'index') ⇒ DirectoryIndex
Returns a new instance of DirectoryIndex.
117 118 119 120 121 122 |
# File 'lib/utopia/redirection.rb', line 117 def initialize(app, index: 'index') @app = app @index = index super(app) end |
Instance Method Details
#[](path) ⇒ Object
124 125 126 127 128 |
# File 'lib/utopia/redirection.rb', line 124 def [] path if path.end_with?('/') return redirect(path + @index) end end |