Class: SqidsWithBlocklistMode

Inherits:
MySqids
  • Object
show all
Defined in:
lib/encoded_id/encoders/sqids_with_blocklist_mode.rb

Overview

Extension of MySqids (vendored Sqids) that adds blocklist mode support. This subclass overrides blocklist checking to support different modes without modifying the vendored library. In the future, the base class can be changed from MySqids to ::Sqids::Sqids once we use the official gem.

Constant Summary

Constants inherited from MySqids

MySqids::DEFAULT_ALPHABET, MySqids::DEFAULT_BLOCKLIST, MySqids::DEFAULT_MIN_LENGTH, MySqids::MAX_INT

Instance Method Summary collapse

Methods inherited from MySqids

#decode, #encode, max_value

Constructor Details

#initialize(options = {}) ⇒ SqidsWithBlocklistMode

Returns a new instance of SqidsWithBlocklistMode.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/encoded_id/encoders/sqids_with_blocklist_mode.rb', line 15

def initialize(options = {})
  @blocklist_mode = options[:blocklist_mode] || :length_threshold
  @blocklist_max_length = options[:blocklist_max_length] || 32

  # Remove our custom options before passing to parent
  parent_options = options.dup
  parent_options.delete(:blocklist_mode)
  parent_options.delete(:blocklist_max_length)

  super(parent_options)
end