Class: Tenon::Redirector
- Inherits:
-
Object
- Object
- Tenon::Redirector
- Defined in:
- app/services/tenon/redirector.rb
Instance Method Summary collapse
-
#initialize(path, redirects = Tenon::Redirect.active) ⇒ Redirector
constructor
A new instance of Redirector.
- #redirect ⇒ Object
Constructor Details
#initialize(path, redirects = Tenon::Redirect.active) ⇒ Redirector
Returns a new instance of Redirector.
12 13 14 15 |
# File 'app/services/tenon/redirector.rb', line 12 def initialize(path, redirects = Tenon::Redirect.active) @path = path @redirects = redirects end |
Instance Method Details
#redirect ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/tenon/redirector.rb', line 17 def redirect # If 404 -> Compare the path to all Redirect records: @destination = get_destination # raise @destination.inspect if @destination.present? # If there is a match return destination: return @destination else # Else -> trigger the 404 again: raise ActiveRecord::RecordNotFound end end |