Class: Journaled::AuditLog::Event

Inherits:
Struct
  • Object
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_operationObject

Returns the value of attribute database_operation

Returns:

  • (Object)

    the current value of database_operation



6
7
8
# File 'app/models/journaled/audit_log/event.rb', line 6

def database_operation
  @database_operation
end

#recordObject

Returns the value of attribute record

Returns:

  • (Object)

    the current value of record



6
7
8
# File 'app/models/journaled/audit_log/event.rb', line 6

def record
  @record
end

#unfiltered_changesObject

Returns the value of attribute unfiltered_changes

Returns:

  • (Object)

    the current value of unfiltered_changes



6
7
8
# File 'app/models/journaled/audit_log/event.rb', line 6

def unfiltered_changes
  @unfiltered_changes
end

Instance Method Details

#actorObject



60
61
62
# File 'app/models/journaled/audit_log/event.rb', line 60

def actor
  Journaled.actor_uri
end

#changesObject



49
50
51
52
53
54
# File 'app/models/journaled/audit_log/event.rb', line 49

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_nameObject



37
38
39
# File 'app/models/journaled/audit_log/event.rb', line 37

def class_name
  record.class.name
end

#created_atObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/journaled/audit_log/event.rb', line 16

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_stream_nameObject



12
13
14
# File 'app/models/journaled/audit_log/event.rb', line 12

def journaled_stream_name
  AuditLog.default_stream_name || super
end

#record_created_atObject



29
30
31
# File 'app/models/journaled/audit_log/event.rb', line 29

def record_created_at
  record.try(:created_at) || Time.zone.now
end

#record_idObject



45
46
47
# File 'app/models/journaled/audit_log/event.rb', line 45

def record_id
  record.id
end

#record_updated_atObject



33
34
35
# File 'app/models/journaled/audit_log/event.rb', line 33

def record_updated_at
  record.try(:updated_at) || Time.zone.now
end

#snapshotObject



56
57
58
# File 'app/models/journaled/audit_log/event.rb', line 56

def snapshot
  filtered_attributes if record._log_snapshot || AuditLog.snapshots_enabled
end

#table_nameObject



41
42
43
# File 'app/models/journaled/audit_log/event.rb', line 41

def table_name
  record.class.table_name
end