Class: Thredded::FriendlyIdReservedWordsAndPagination

Inherits:
Object
  • Object
show all
Defined in:
app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb

Overview

Excludes pagination routes in addition to the given list of reserved words.

Constant Summary collapse

PAGINATION_PATTERN =
/\Apage-\d+\z/i

Instance Method Summary collapse

Constructor Details

#initialize(words = []) ⇒ FriendlyIdReservedWordsAndPagination

Returns a new instance of FriendlyIdReservedWordsAndPagination.



9
10
11
# File 'app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb', line 9

def initialize(words = [])
  @words = Set.new(words)
end

Instance Method Details

#include?(slug) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb', line 13

def include?(slug)
  @words.include?(slug) || PAGINATION_PATTERN.match?(slug)
end