class Mintaka::Constraints::RootRoute

Routing constraint to validate request.path has a corresponding view

Public Class Methods

matches?(request) click to toggle source
# File lib/mintaka/constraints/root_route.rb, line 6
def matches?(request)
  page_id = clean_page_path(request.path)
  pattern = file_pattern(page_id)

  Dir.glob(pattern).any?
end

Private Class Methods

clean_page_path(request_path) click to toggle source
# File lib/mintaka/constraints/root_route.rb, line 15
def clean_page_path(request_path)
  request_path.sub(/\.html$/, "")
end
content_path() click to toggle source
# File lib/mintaka/constraints/root_route.rb, line 23
def content_path
  Rails.root.join("app", "views", Mintaka.content_path).to_s
end
file_pattern(page_id) click to toggle source
# File lib/mintaka/constraints/root_route.rb, line 19
def file_pattern(page_id)
  "#{content_path}#{page_id}.html*"
end