class ActiveEncryption::EncryptionSetting::Record
The ActiveEncryption::EncryptionSetting::Record
contains the required settings for encrypting and decrypting content.
Constants
- ATTRIBUTES
Public Class Methods
merge(base_record, higher_priority_record)
click to toggle source
# File lib/active_encryption/encryption_setting/record.rb, line 25 def self.merge(base_record, higher_priority_record) new( to_h(base_record) .merge(key: nil) # reset the computed key .merge( to_h(higher_priority_record) ) ) end
new(attributes)
click to toggle source
# File lib/active_encryption/encryption_setting/record.rb, line 35 def initialize(attributes) ATTRIBUTES.each do |name| instance_variable_set("@#{name}", attributes[name]) end @serializer = Object.const_get(@serializer) if @serializer.is_a?(String) end
to_h(record)
click to toggle source
# File lib/active_encryption/encryption_setting/record.rb, line 15 def self.to_h(record) if record.is_a?(Hash) record.slice(*ATTRIBUTES) else ATTRIBUTES.each_with_object({}) do |name, attributes| attributes[name] = record.public_send(name) end end end
Public Instance Methods
key()
click to toggle source
# File lib/active_encryption/encryption_setting/record.rb, line 43 def key @key ||= Key.new( secret, cipher: cipher, salt: secret_salt, iterations: secret_iterations ).value end
to_h()
click to toggle source
# File lib/active_encryption/encryption_setting/record.rb, line 52 def to_h self.class.to_h(self) end