class LoggableActivity::Payload

This class represents a payload in the log, containing encrypted data of one record in the database. When the record is deleted, the encryption key for the payload is also deleted. Payloads come in different types, each serving a specific purpose.

Public Instance Methods

attrs() click to toggle source

Returns the decrypted attributes of the payload based on its type.

@return [Hash] The decrypted attributes.

Example:

payload.attrs

Returns:
{
         "street" => "Machu Picchu",
           "city" => "Aguas Calientes",
        "country" => "Peru",
    "postal_code" => "08680"
}
# File lib/loggable_activity/payload.rb, line 38
def attrs
  return deleted_attrs if record.nil?

  case payload_type
  when 'current_association', 'primary_payload', 'previous_association'
    decrypted_attrs
  when 'update_payload'
    decrypted_update_attrs
  end
end