Class: Datadog::AppSec::Contrib::Devise::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/appsec/contrib/devise/event.rb

Overview

Class to extract event information from the resource

Constant Summary collapse

UUID_REGEX =
/^\h{8}-\h{4}-\h{4}-\h{4}-\h{12}$/.freeze
SAFE_MODE =
'safe'
EXTENDED_MODE =
'extended'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, mode) ⇒ Event

Returns a new instance of Event.



16
17
18
19
20
21
22
23
24
# File 'lib/datadog/appsec/contrib/devise/event.rb', line 16

def initialize(resource, mode)
  @resource = resource
  @mode = mode
  @user_id = nil
  @email = nil
  @username = nil

  extract if @resource
end

Instance Attribute Details

#user_idObject (readonly)

Returns the value of attribute user_id.



14
15
16
# File 'lib/datadog/appsec/contrib/devise/event.rb', line 14

def user_id
  @user_id
end

Instance Method Details

#to_hObject



26
27
28
29
30
31
32
33
# File 'lib/datadog/appsec/contrib/devise/event.rb', line 26

def to_h
  return @event if defined?(@event)

  @event = {}
  @event[:email] = @email if @email
  @event[:username] = @username if @username
  @event
end