Module: Philiprehberger::AuditTrail::Exportable

Included in:
Tracker
Defined in:
lib/philiprehberger/audit_trail/exportable.rb

Overview

Export audit events to JSON or CSV format.

Constant Summary collapse

EXPORT_HEADERS =
%w[entity_id entity_type action actor timestamp].freeze

Instance Method Summary collapse

Instance Method Details

#export(format) ⇒ String

Export all events in the specified format.

Parameters:

  • format (Symbol)

    :json or :csv

Returns:

  • (String)

    formatted output



17
18
19
20
21
22
23
# File 'lib/philiprehberger/audit_trail/exportable.rb', line 17

def export(format)
  case format
  when :json then export_json
  when :csv then export_csv
  else raise ArgumentError, "unsupported format: #{format}"
  end
end