module Portunus::Encryptable

Public Instance Methods

encrypted_fields(*fields) click to toggle source
# File lib/portunus/encryptable.rb, line 10
def encrypted_fields(*fields)
  fields.map do |field|
    ::Portunus::FieldConfigurer.for(self, field)
  end
end
encrypted_fields_list() click to toggle source
# File lib/portunus/encryptable.rb, line 6
def encrypted_fields_list
  @_encrypted_fields_list ||= []
end

Private Instance Methods

hash_encrypted_fields() click to toggle source
# File lib/portunus/encryptable.rb, line 29
def hash_encrypted_fields
  self.class.encrypted_fields_list.each do |field|
    hashed_field_name = "hashed_#{field}".to_sym

    if respond_to?(hashed_field_name)
      write_attribute(
        hashed_field_name,
        ::Portunus::Hasher.for(send(field.to_sym))
      )
    end
  end
end