Class: AuditEventService

Inherits:
Object
  • Object
show all
Defined in:
app/services/audit_event_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(author, entity, details = {}) ⇒ AuditEventService

Returns a new instance of AuditEventService


2
3
4
# File 'app/services/audit_event_service.rb', line 2

def initialize(author, entity, details = {})
  @author, @entity, @details = author, entity, details
end

Instance Method Details

#for_authenticationObject


6
7
8
9
10
11
12
13
14
15
# File 'app/services/audit_event_service.rb', line 6

def for_authentication
  @details = {
    with: @details[:with],
    target_id: @author.id,
    target_type: "User",
    target_details: @author.name,
  }

  self
end

#security_eventObject


17
18
19
20
21
22
23
24
# File 'app/services/audit_event_service.rb', line 17

def security_event
  SecurityEvent.create(
    author_id: @author.id,
    entity_id: @entity.id,
    entity_type: @entity.class.name,
    details: @details
  )
end