Sha256: d1e71020a3eea9bc26704f34b36282890cecb37fd5ab5042dab66d5334b8b47a
Contents?: true
Size: 607 Bytes
Versions: 8
Compression:
Stored size: 607 Bytes
Contents
# frozen_string_literal: true module EncodedId module Rails class Salt def initialize(klass, salt) @klass = klass @salt = salt end def generate! unless @klass.respond_to?(:name) && @klass.name.present? raise ::StandardError, "The class must have a `name` to ensure encode id uniqueness. " \ "Please set a name on the class or override `encoded_id_salt`." end raise ::StandardError, "Encoded ID salt is invalid" if !@salt || @salt.blank? || @salt.size < 4 "#{@klass.name}/#{@salt}" end end end end
Version data entries
8 entries across 8 versions & 1 rubygems