Class: HighVoltage::Constraints::RootRoute
- Inherits:
-
Object
- Object
- HighVoltage::Constraints::RootRoute
- Defined in:
- lib/high_voltage/constraints/root_route.rb
Overview
Routing constraint to validate request.path has a corresponding view
Instance Method Summary collapse
-
#initialize ⇒ RootRoute
constructor
A new instance of RootRoute.
- #matches?(request) ⇒ Boolean
Constructor Details
#initialize ⇒ RootRoute
Returns a new instance of RootRoute.
5 6 7 8 9 |
# File 'lib/high_voltage/constraints/root_route.rb', line 5 def initialize @lookup_context = ActionView::LookupContext.new( Rails.configuration.paths["app/views"], ) end |
Instance Method Details
#matches?(request) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/high_voltage/constraints/root_route.rb', line 11 def matches?(request) page_id = clean_page_path(request.path) template = File.join(content_path, page_id) lookup_context.exists? template end |