Class: Vangrail::AuditEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/vangrail/audit.rb

Overview

Immutable structured event emitted by enforcement operations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type:, timestamp:, data:) ⇒ AuditEvent

Returns a new instance of AuditEvent.



12
13
14
15
16
17
18
# File 'lib/vangrail/audit.rb', line 12

def initialize(id:, type:, timestamp:, data:)
  @id = id.to_s.freeze
  @type = type.to_sym
  @at = timestamp.to_s.freeze
  @data = data.freeze
  freeze
end

Instance Attribute Details

#atObject (readonly)

Returns the value of attribute at.



10
11
12
# File 'lib/vangrail/audit.rb', line 10

def at
  @at
end

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/vangrail/audit.rb', line 10

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/vangrail/audit.rb', line 10

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/vangrail/audit.rb', line 10

def type
  @type
end

Instance Method Details

#to_hObject



20
21
22
# File 'lib/vangrail/audit.rb', line 20

def to_h
  { 'id' => id, 'type' => type.to_s, 'at' => at, 'data' => data }
end