class CryptKeeper::Provider::PostgresBase

Constants

INVALID_DATA_ERROR

Public Instance Methods

encrypted?(value) click to toggle source

Public: Checks if value is already encrypted.

Returns boolean

# File lib/crypt_keeper/provider/postgres_base.rb, line 14
def encrypted?(value)
  begin
    escape_and_execute_sql(["SELECT pgp_key_id(?)", value.to_s],
      new_transaction: true)['pgp_key_id'].present?
  rescue ActiveRecord::StatementInvalid => e
    if e.message.include?(INVALID_DATA_ERROR)
      false
    else
      raise
    end
  end
end