Module: KmsRails::ActiveRecord::InstanceMethods
- Defined in:
- lib/kms_rails/active_record.rb
Instance Method Summary collapse
- #clear_retained(field) ⇒ Object
- #get_hash(field) ⇒ Object
- #get_retained(field) ⇒ Object
- #set_retained(field, plaintext) ⇒ Object
- #store_hash(field, data) ⇒ Object
Instance Method Details
#clear_retained(field) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/kms_rails/active_record.rb', line 87 def clear_retained(field) @_retained ||= {} return if !@_retained.include?(field) || @_retained[field].nil? Core.shred_string(@_retained[field]) @_retained[field] = nil end |
#get_hash(field) ⇒ Object
66 67 68 69 |
# File 'lib/kms_rails/active_record.rb', line 66 def get_hash(field) hash = read_attribute("#{field}_enc") hash ? MessagePack.unpack(hash) : nil end |
#get_retained(field) ⇒ Object
71 72 73 74 |
# File 'lib/kms_rails/active_record.rb', line 71 def get_retained(field) @_retained ||= {} @_retained[field] end |
#set_retained(field, plaintext) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/kms_rails/active_record.rb', line 76 def set_retained(field, plaintext) @_retained ||= {} if @_retained[field] Core.shred_string(@_retained[field]) @_retained[field] = nil end @_retained[field] = plaintext.dup end |
#store_hash(field, data) ⇒ Object
62 63 64 |
# File 'lib/kms_rails/active_record.rb', line 62 def store_hash(field, data) self["#{field}_enc"] = data.to_msgpack end |