Sha256: 8e13d8573bc0ceaaa8ed0dbb8e838e40ea147ca2da4cd6a92649a85d2e9b870a

Contents?: true

Size: 445 Bytes

Versions: 29

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  class PagePathConstraint
    def matches?(request)
      locale?(request.path_parameters[:locale]) &&
        exists?(
          request.path_parameters[:locale],
          request.path_parameters[:path]
        )
    end

    private

    def locale?(str)
      str.to_s =~ /\A[a-z]{2}\z/
    end

    def exists?(locale, path)
      PagePath.get(locale, path) ? true : false
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pages_core-3.15.5 lib/pages_core/page_path_constraint.rb
pages_core-3.15.4 lib/pages_core/page_path_constraint.rb
pages_core-3.15.3 lib/pages_core/page_path_constraint.rb
pages_core-3.15.2 lib/pages_core/page_path_constraint.rb
pages_core-3.15.1 lib/pages_core/page_path_constraint.rb
pages_core-3.14.0 lib/pages_core/page_path_constraint.rb
pages_core-3.13.0 lib/pages_core/page_path_constraint.rb
pages_core-3.12.7 lib/pages_core/page_path_constraint.rb
pages_core-3.12.6 lib/pages_core/page_path_constraint.rb
pages_core-3.12.5 lib/pages_core/page_path_constraint.rb
pages_core-3.12.4 lib/pages_core/page_path_constraint.rb
pages_core-3.12.3 lib/pages_core/page_path_constraint.rb
pages_core-3.12.2 lib/pages_core/page_path_constraint.rb
pages_core-3.12.1 lib/pages_core/page_path_constraint.rb
pages_core-3.12.0 lib/pages_core/page_path_constraint.rb
pages_core-3.11.3 lib/pages_core/page_path_constraint.rb
pages_core-3.11.2 lib/pages_core/page_path_constraint.rb
pages_core-3.11.1 lib/pages_core/page_path_constraint.rb
pages_core-3.11.0 lib/pages_core/page_path_constraint.rb
pages_core-3.10.2 lib/pages_core/page_path_constraint.rb