Class: Timber::Contexts::Session

Inherits:
Timber::Context
  • Object
show all
Defined in:
lib/timber/contexts/session.rb

Overview

Note:

This is tracked automatically with the Integrations::Rack::SessionContext rack middleware.

The session context tracks the current session for the given user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Session

Returns a new instance of Session.



12
13
14
# File 'lib/timber/contexts/session.rb', line 12

def initialize(attributes)
  @id = attributes[:id] || raise(ArgumentError.new(":id is required"))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/timber/contexts/session.rb', line 10

def id
  @id
end

Instance Method Details

#as_json(_options = {}) ⇒ Object



16
17
18
# File 'lib/timber/contexts/session.rb', line 16

def as_json(_options = {})
  {id: Timber::Util::Object.try(id, :to_s)}
end