Class: Logtail::Contexts::User
- Inherits:
-
Logtail::Context
- Object
- Logtail::Context
- Logtail::Contexts::User
- Defined in:
- lib/logtail/contexts/user.rb
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
-
#initialize(attributes) ⇒ User
constructor
A new instance of User.
-
#to_hash ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
10 11 12 13 14 |
# File 'lib/logtail/contexts/user.rb', line 10 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.
8 9 10 |
# File 'lib/logtail/contexts/user.rb', line 8 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/logtail/contexts/user.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/logtail/contexts/user.rb', line 8 def name @name end |
Instance Method Details
#to_hash ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
17 18 19 20 21 22 23 24 25 |
# File 'lib/logtail/contexts/user.rb', line 17 def to_hash @to_hash ||= { user: Util::NonNilHashBuilder.build do |h| h.add(:id, id) h.add(:name, name) h.add(:email, email) end } end |