Module: EzLogsAgent::Actor
- Defined in:
- lib/ez_logs_agent/actor.rb
Overview
Manages actor context for the current request.
Actor represents “who triggered this action” - the logged-in user.
Actor schema:
id: String, # REQUIRED - stable identifier (e.g., user.id)
label: String # optional - human-readable display (e.g., user.email)
Usage:
# Configured via actor_from_request hook in EzLogsAgent.configure
Class Method Summary collapse
-
.clear ⇒ void
Clear the current actor.
-
.current ⇒ Hash?
Get the current actor for this request.
-
.current=(actor) ⇒ Hash?
Set the current actor for this request Validates and sanitizes the actor before storing.
Class Method Details
.clear ⇒ void
This method returns an undefined value.
Clear the current actor
50 51 52 53 54 |
# File 'lib/ez_logs_agent/actor.rb', line 50 def clear RequestStore.store[:ez_logs_actor] = nil rescue => e EzLogsAgent::Logger.debug("[Actor] clear failed: #{e.}") end |
.current ⇒ Hash?
Get the current actor for this request
22 23 24 25 26 27 |
# File 'lib/ez_logs_agent/actor.rb', line 22 def current RequestStore.store[:ez_logs_actor] rescue => e EzLogsAgent::Logger.debug("[Actor] current failed: #{e.}") nil end |
.current=(actor) ⇒ Hash?
Set the current actor for this request Validates and sanitizes the actor before storing
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ez_logs_agent/actor.rb', line 33 def current=(actor) validated = ActorValidator.sanitize(actor) # Log debug message if actor was invalid (user hook misconfiguration) if actor && validated.nil? EzLogsAgent::Logger.debug("[Actor] Invalid actor structure ignored: #{actor.inspect}") end RequestStore.store[:ez_logs_actor] = validated validated rescue => e EzLogsAgent::Logger.debug("[Actor] current= failed: #{e.}") nil end |