Sha256: a53ac786102a9fd40caea1c1949fa37e7cdcd33e68633e0c104398e39b7b40f1

Contents?: true

Size: 486 Bytes

Versions: 2

Compression:

Stored size: 486 Bytes

Contents

module Brightcontent
  module Pages
    class PathConstraint
      CACHE_KEY = :brightcontent_page_slugs

      def self.expire
        Rails.cache.delete(CACHE_KEY)
      end

      def matches?(request)
        slug = Page.sanitize_path(request.path)
        cached_page_slugs.include?(slug)
      end

      private

      def cached_page_slugs
        Rails.cache.fetch(CACHE_KEY) { page_slugs }
      end

      def page_slugs
        Page.pluck(:slug)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brightcontent-pages-2.1.1 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.1.0 lib/brightcontent/pages/path_constraint.rb