Class: Sqids

Inherits:
Object
  • Object
show all
Defined in:
lib/neat_ids.rb

Overview

The upstream sqids gem derives its max encodable number from 0.size (the machine word size). On 32-bit platforms (e.g. arm32) that yields 2**30 - 1 = 1073741823, which is too small for the 32-bit integer chunks used to encode UUIDs and breaks encoding on machines like the Raspberry Pi 2. max_value only acts as an upper-bound guard in Sqids#encode; it does not affect the encoding/decoding algorithm, so pinning it to a fixed constant is safe and produces identical IDs on every platform.

Class Method Summary collapse

Class Method Details

.max_valueObject



14
15
16
# File 'lib/neat_ids.rb', line 14

def self.max_value
  9007199254740991 # 2**53 - 1, per the Sqids spec
end