Class: RailsAuditLog::PaperTrailCompat::Proxy
- Inherits:
-
Object
- Object
- RailsAuditLog::PaperTrailCompat::Proxy
- Defined in:
- lib/rails_audit_log/paper_trail_compat.rb
Overview
Proxy providing the PaperTrail instance API surface backed by AuditLogEntry records.
Instance Method Summary collapse
-
#initialize(record) ⇒ Proxy
constructor
A new instance of Proxy.
-
#originator ⇒ String?
Display name of the actor who made the most recent change, as stored in
whodunnit_snapshot. -
#previous_version ⇒ ActiveRecord::Base?
Reconstructs the record’s state before the most recent change.
-
#version ⇒ AuditLogEntry?
The most recent AuditLogEntry for the record.
-
#version_at(timestamp) ⇒ ActiveRecord::Base?
Reconstructs the record’s state as it was at
timestamp.
Constructor Details
#initialize(record) ⇒ Proxy
Returns a new instance of Proxy.
39 40 41 |
# File 'lib/rails_audit_log/paper_trail_compat.rb', line 39 def initialize(record) @record = record end |
Instance Method Details
#originator ⇒ String?
Display name of the actor who made the most recent change, as stored in whodunnit_snapshot.
62 63 64 |
# File 'lib/rails_audit_log/paper_trail_compat.rb', line 62 def originator version&.whodunnit_snapshot end |
#previous_version ⇒ ActiveRecord::Base?
Reconstructs the record’s state before the most recent change. Returns nil for newly created records (no prior state exists).
54 55 56 |
# File 'lib/rails_audit_log/paper_trail_compat.rb', line 54 def previous_version version&.reify end |
#version ⇒ AuditLogEntry?
The most recent AuditLogEntry for the record.
46 47 48 |
# File 'lib/rails_audit_log/paper_trail_compat.rb', line 46 def version @record.audit_log_entries.order(id: :desc).first end |
#version_at(timestamp) ⇒ ActiveRecord::Base?
Reconstructs the record’s state as it was at timestamp. Delegates to RailsAuditLog.version_at.
71 72 73 |
# File 'lib/rails_audit_log/paper_trail_compat.rb', line 71 def version_at() RailsAuditLog.version_at(@record, ) end |