module SecretId::Base::ClassMethods

Public Instance Methods

decode_id(hashed_id) click to toggle source
# File lib/secret_id/base.rb, line 28
def decode_id(hashed_id)
  self.hashids.decode(hashed_id).first
end
encode_id(id) click to toggle source
# File lib/secret_id/base.rb, line 32
def encode_id(id)
  self.hashids.encode(id)
end
secret_id(options = {}) click to toggle source
# File lib/secret_id/base.rb, line 18
def secret_id(options = {})
  options = default_options.merge(options)

  self.hashids = Hashids.new(
    options[:salt],
    options[:min_length],
    options[:alphabet]
  )
end

Private Instance Methods

default_options() click to toggle source
# File lib/secret_id/base.rb, line 38
def default_options
  {
    salt: name,
    min_length: 3,
    alphabet: Hashids::DEFAULT_ALPHABET
  }
end