Class: CommandTower::Serializers::Audit::Events::EventSerializer

Inherits:
CommandTower::Serializers::ApplicationSerializer show all
Defined in:
app/serializers/command_tower/serializers/audit/events.rb

Class Method Summary collapse

Methods inherited from CommandTower::Serializers::ApplicationSerializer

iso8601, map_serialize

Class Method Details

.serialize(projection) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/serializers/command_tower/serializers/audit/events.rb', line 8

def self.serialize(projection)
  {
    id: projection.fetch(:id),
    eventName: projection.fetch(:event_name),
    eventLabel: projection.fetch(:event_label),
    occurredAt: iso8601(projection.fetch(:occurred_at)),
    attributionMode: projection.fetch(:attribution_mode),
    actor: { userId: projection[:actor_user_id] },
    affectedUser: { userId: projection[:affected_user_id] },
    subject: {
      type: projection[:subject_type],
      id: projection[:subject_id],
      label: projection[:subject_label]
    },
    impersonationActive: projection.fetch(:impersonation_active),
    originatingAdministratorId: projection[:originating_administrator_id],
    changes: projection.fetch(:changes),
    metadata: projection.fetch(:metadata)
  }
end