Sha256: fa15a499eeafa624405b49736b43cec1bc6c4ddbed34080f040ee2366347d445

Contents?: true

Size: 526 Bytes

Versions: 22

Compression:

Stored size: 526 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 = Brightcontent.page_model.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
        Brightcontent.page_model.pluck(:slug)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
brightcontent-pages-2.6.0 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.5.1 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.5.0 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.6 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.5 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.4 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.3 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.2 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.1 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.4.0 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.3.4 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.3.3 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.3.2 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.3.1 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.3.0 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.2.2 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.2.1 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.2.0 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.1.5 lib/brightcontent/pages/path_constraint.rb
brightcontent-pages-2.1.4 lib/brightcontent/pages/path_constraint.rb