Class: ActionEncrypt::DataEncryptionKey
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActionEncrypt::DataEncryptionKey
- Defined in:
- app/models/action_encrypt/data_encryption_key.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.generate!(attrs = {}) ⇒ Object
8 9 10 |
# File 'app/models/action_encrypt/data_encryption_key.rb', line 8 def self.generate!(attrs={}) create!(attrs.merge(key: SecureRandom.hex(32))) end |
Instance Method Details
#encryption_key ⇒ Object
12 13 14 |
# File 'app/models/action_encrypt/data_encryption_key.rb', line 12 def encryption_key [ActionEncrypt.configuration.key_encryption_key].pack("H*") end |
#promote! ⇒ Object
16 17 18 19 20 21 |
# File 'app/models/action_encrypt/data_encryption_key.rb', line 16 def promote! transaction do DataEncryptionKey.primary.update_attributes!(primary: false) update_attributes!(primary: true) end end |