Class: Thesis::RouteConstraint
- Inherits:
-
Object
- Object
- Thesis::RouteConstraint
- Defined in:
- lib/thesis/routing/route_constraint.rb
Instance Method Summary collapse
Instance Method Details
#excluded_path?(path) ⇒ Boolean
9 10 11 12 |
# File 'lib/thesis/routing/route_constraint.rb', line 9 def excluded_path?(path) excluded_extensions = [ :jpg, :jpeg, :png, :css, :js, :ico, :pdf ] excluded_extensions.any?{ |ext| path.ends_with?(".#{ext}") } end |
#matches?(request) ⇒ Boolean
3 4 5 6 7 |
# File 'lib/thesis/routing/route_constraint.rb', line 3 def matches?(request) slug = request.path.to_s.sub(/(\/)+$/,'') return false if excluded_path?(slug) Page.where(slug: slug).size > 0 end |