Class: Journaled::AuditLog::Event
- Inherits:
-
Struct
- Object
- Struct
- Journaled::AuditLog::Event
show all
- Includes:
- Event
- Defined in:
- app/models/journaled/audit_log/event.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Event
#event_type, #id, #journal!, #journaled_attributes, #journaled_partition_key, #journaled_schema_name, #tagged?
Instance Attribute Details
#database_operation ⇒ Object
Returns the value of attribute database_operation
8
9
10
|
# File 'app/models/journaled/audit_log/event.rb', line 8
def database_operation
@database_operation
end
|
#enqueue_opts ⇒ Object
Returns the value of attribute enqueue_opts
8
9
10
|
# File 'app/models/journaled/audit_log/event.rb', line 8
def enqueue_opts
@enqueue_opts
end
|
#record ⇒ Object
Returns the value of attribute record
8
9
10
|
# File 'app/models/journaled/audit_log/event.rb', line 8
def record
@record
end
|
#unfiltered_changes ⇒ Object
Returns the value of attribute unfiltered_changes
8
9
10
|
# File 'app/models/journaled/audit_log/event.rb', line 8
def unfiltered_changes
@unfiltered_changes
end
|
Instance Method Details
#actor ⇒ Object
67
68
69
|
# File 'app/models/journaled/audit_log/event.rb', line 67
def actor
Journaled.actor_uri
end
|
#changes ⇒ Object
55
56
57
58
59
60
|
# File 'app/models/journaled/audit_log/event.rb', line 55
def changes
filtered_changes = unfiltered_changes.deep_dup.deep_symbolize_keys
filtered_changes.each do |key, value|
filtered_changes[key] = value.map { |val| '[FILTERED]' if val } if filter_key?(key)
end
end
|
#class_name ⇒ Object
43
44
45
|
# File 'app/models/journaled/audit_log/event.rb', line 43
def class_name
record.class.name
end
|
#created_at ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/journaled/audit_log/event.rb', line 22
def created_at
case database_operation
when 'insert'
record_created_at
when 'update'
record_updated_at
when 'delete'
Time.zone.now
else
raise "Unhandled database operation type: #{database_operation}"
end
end
|
#journaled_enqueue_opts ⇒ Object
18
19
20
|
# File 'app/models/journaled/audit_log/event.rb', line 18
def journaled_enqueue_opts
record.class.audit_log_config.enqueue_opts
end
|
#journaled_stream_name ⇒ Object
14
15
16
|
# File 'app/models/journaled/audit_log/event.rb', line 14
def journaled_stream_name
AuditLog.default_stream_name || super
end
|
#record_created_at ⇒ Object
35
36
37
|
# File 'app/models/journaled/audit_log/event.rb', line 35
def record_created_at
record.try(:created_at) || Time.zone.now
end
|
#record_id ⇒ Object
51
52
53
|
# File 'app/models/journaled/audit_log/event.rb', line 51
def record_id
record.id
end
|
#record_updated_at ⇒ Object
39
40
41
|
# File 'app/models/journaled/audit_log/event.rb', line 39
def record_updated_at
record.try(:updated_at) || Time.zone.now
end
|
#snapshot ⇒ Object
62
63
64
65
|
# File 'app/models/journaled/audit_log/event.rb', line 62
def snapshot
filtered_attributes if record._log_snapshot || AuditLog.snapshots_enabled ||
(database_operation == 'delete' && AuditLog.snapshot_on_deletion)
end
|
#table_name ⇒ Object
47
48
49
|
# File 'app/models/journaled/audit_log/event.rb', line 47
def table_name
record.class.table_name
end
|