Sha256: ce0201acc84daf6a332f1776205b81b57924c03fbbf696de09ebb88d0108416e

Contents?: true

Size: 488 Bytes

Versions: 9

Compression:

Stored size: 488 Bytes

Contents

module HighVoltage
  module Constraints
    # Routing constraint to validate request.path has a corresponding view
    class RootRoute
      def self.matches?(request)
        pattern = file_pattern(request.path)

        Dir.glob(pattern).any?
      end

      private

      def self.file_pattern(page_id)
        "#{content_path}#{page_id}.html*"
      end

      def self.content_path
        Rails.root.join('app', 'views', HighVoltage.content_path).to_s
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
high_voltage-2.4.0 lib/high_voltage/constraints/root_route.rb
high_voltage-2.3.0 lib/high_voltage/constraints/root_route.rb
high_voltage-2.2.1 lib/high_voltage/constraints/root_route.rb
high_voltage-2.2.0 lib/high_voltage/constraints/root_route.rb
high_voltage-2.1.0 lib/high_voltage/constraints/root_route.rb
high_voltage-2.0.0 lib/high_voltage/constraints/root_route.rb
high_voltage-1.2.4 lib/high_voltage/constraints/root_route.rb
high_voltage-1.2.3 lib/high_voltage/constraints/root_route.rb
high_voltage-1.2.2 lib/high_voltage/constraints/root_route.rb