Class: IronAdmin::AuditLog::Entry
- Inherits:
-
Object
- Object
- IronAdmin::AuditLog::Entry
- Defined in:
- lib/iron_admin/audit_log.rb
Overview
Represents a single audit log entry.
Contains details about who performed what action on which record.
Instance Attribute Summary collapse
-
#action ⇒ Symbol
The action type (:create, :update, :delete).
-
#changes ⇒ Hash
The attribute changes (for updates).
-
#ip_address ⇒ String
The IP address of the request.
-
#record_id ⇒ Integer, String
The ID of the affected record.
-
#resource ⇒ String
The resource name (e.g., "users").
-
#timestamp ⇒ Time
When the action occurred.
-
#user ⇒ Object
The user who performed the action.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Entry
constructor
Creates a new audit entry.
-
#to_h ⇒ Hash
Converts the entry to a hash.
Constructor Details
#initialize(attrs = {}) ⇒ Entry
Creates a new audit entry.
72 73 74 75 |
# File 'lib/iron_admin/audit_log.rb', line 72 def initialize(attrs = {}) attrs.each { |k, v| send("#{k}=", v) } @timestamp ||= Time.current end |
Instance Attribute Details
#action ⇒ Symbol
Returns The action type (:create, :update, :delete).
45 46 47 |
# File 'lib/iron_admin/audit_log.rb', line 45 def action @action end |
#changes ⇒ Hash
Returns The attribute changes (for updates).
54 55 56 |
# File 'lib/iron_admin/audit_log.rb', line 54 def changes @changes end |
#ip_address ⇒ String
Returns The IP address of the request.
57 58 59 |
# File 'lib/iron_admin/audit_log.rb', line 57 def ip_address @ip_address end |
#record_id ⇒ Integer, String
Returns The ID of the affected record.
51 52 53 |
# File 'lib/iron_admin/audit_log.rb', line 51 def record_id @record_id end |
#resource ⇒ String
Returns The resource name (e.g., "users").
48 49 50 |
# File 'lib/iron_admin/audit_log.rb', line 48 def resource @resource end |
#timestamp ⇒ Time
Returns When the action occurred.
60 61 62 |
# File 'lib/iron_admin/audit_log.rb', line 60 def @timestamp end |
#user ⇒ Object
Returns The user who performed the action.
42 43 44 |
# File 'lib/iron_admin/audit_log.rb', line 42 def user @user end |
Instance Method Details
#to_h ⇒ Hash
Converts the entry to a hash.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/iron_admin/audit_log.rb', line 80 def to_h { user: user, action: action, resource: resource, record_id: record_id, changes: changes, ip_address: ip_address, timestamp: , } end |