Class: AuditLoggable::AuditRecord
- Inherits:
-
Object
- Object
- AuditLoggable::AuditRecord
- Defined in:
- lib/audit_loggable/audit_record.rb
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
-
#initialize(auditable, user, action, changeset, remote_address, request_uuid) ⇒ AuditRecord
constructor
A new instance of AuditRecord.
Constructor Details
#initialize(auditable, user, action, changeset, remote_address, request_uuid) ⇒ AuditRecord
Returns a new instance of AuditRecord.
5 6 7 8 9 10 11 12 |
# File 'lib/audit_loggable/audit_record.rb', line 5 def initialize(auditable, user, action, changeset, remote_address, request_uuid) @auditable = auditable @user = user @action = action @changeset = changeset @remote_address = remote_address @request_uuid = request_uuid end |
Instance Method Details
#as_json(options = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/audit_loggable/audit_record.rb', line 14 def as_json( = nil) { auditable: { id: auditable.id, type: auditable.class.polymorphic_name }, user: user ? { id: user.id, type: user.class.polymorphic_name } : nil, action: action, changes: changeset.to_json, # serialize to JSON string remote_address: remote_address, request_uuid: request_uuid }.as_json() end |