Class: CryptKeeper::Provider::PostgresBase
- Includes:
- Helper::SQL, LogSubscriber::PostgresPgp
- Defined in:
- lib/crypt_keeper/provider/postgres_base.rb
Direct Known Subclasses
Constant Summary collapse
- INVALID_DATA_ERROR =
"Wrong key or corrupt data".freeze
Constants included from LogSubscriber::PostgresPgp
LogSubscriber::PostgresPgp::FILTER
Instance Method Summary collapse
-
#encrypted?(value) ⇒ Boolean
Public: Checks if value is already encrypted.
Methods included from LogSubscriber::PostgresPgp
Methods inherited from Base
Instance Method Details
#encrypted?(value) ⇒ Boolean
Public: Checks if value is already encrypted.
Returns boolean
14 15 16 17 18 19 20 21 22 23 24 25 |
# 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..include?(INVALID_DATA_ERROR) false else raise end end end |