Module: FakerMaker::Auditable

Included in:
Factory
Defined in:
lib/faker_maker/auditable.rb

Overview

Mix-in module which provides the auditable functionality

Instance Method Summary collapse

Instance Method Details

#audit(instance) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/faker_maker/auditable.rb', line 7

def audit(instance)
  envelope = audit_envelope(class: instance.class.name, body: instance.as_json)
  audit_stream.puts(JSON.generate(envelope))
  audit_stream.flush if audit_stream.respond_to?(:flush)
rescue StandardError => e
  warn "FakerMaker Warning: #{e.class}: \"#{e.message}\" occurred. FakerMaker will disable audit logging. " \
       'Further warnings supressed.'
  FakerMaker.configuration.audit = false
end