module EncryptedId::ClassMethods

Public Instance Methods

encrypted_id_default_key() click to toggle source
# File lib/encrypted_id.rb, line 51
def encrypted_id_default_key
  name
end
find(*args) click to toggle source
Calls superclass method
# File lib/encrypted_id.rb, line 33
def find(*args)
  scope = args.slice!(0)
  options = args.slice!(0) || {}
  if !(scope.is_a? Symbol) && has_encrypted_id? && !options[:no_encrypted_id]
    begin
      scope = EncryptedId.decrypt(encrypted_id_key, "#{scope}")
    rescue OpenSSL::Cipher::CipherError
      raise ActiveRecord::RecordNotFound.new("Could not decrypt ID #{args[0]}")
    end
  end
  options.delete(:no_encrypted_id)
  super(scope, options)
end
has_encrypted_id?() click to toggle source
# File lib/encrypted_id.rb, line 47
def has_encrypted_id?
  true
end