Class: Timber::Contexts::User
- Inherits:
-
Timber::Context
- Object
- Timber::Context
- Timber::Contexts::User
- Defined in:
- lib/timber/contexts/user.rb
Overview
Note:
This is tracked automatically with the Integrations::Rack::UserContext rack middleware.
The user context tracks the currently authenticated user.
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(attributes) ⇒ User
12 13 14 15 16 |
# File 'lib/timber/contexts/user.rb', line 12 def initialize(attributes) @id = attributes[:id] @name = attributes[:name] @email = attributes[:email] end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
10 11 12 |
# File 'lib/timber/contexts/user.rb', line 10 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/timber/contexts/user.rb', line 10 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/timber/contexts/user.rb', line 10 def name @name end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
18 19 20 |
# File 'lib/timber/contexts/user.rb', line 18 def as_json( = {}) {id: Timber::Util::Object.try(id, :to_s), name: name, email: email} end |