Sha256: 3ed0deb835d77d71acf0d020bbc9b15e0f44ca8aa0d04ce57ff91146e912ce1c
Contents?: true
Size: 1.07 KB
Versions: 13
Compression:
Stored size: 1.07 KB
Contents
require "timber/context" require "timber/util" module Timber module Contexts # The user context adds data about the currently authenticated user to your logs. # By adding this context all of your logs will contain user information. This allows # filter and tail logs by specific users. # # @note This is tracked automatically with the {Integrations::Rack::UserContext} rack # middleware for supported authentication frameworks. See {Integrations::Rack::UserContext} # for more details. class User < Context @keyspace = :user attr_reader :id, :name, :email, :type, :meta def initialize(attributes) @id = Timber::Util::Object.try(attributes[:id], :to_s) @name = attributes[:name] @email = attributes[:email] @type = attributes[:type] @meta = attributes[:meta] end # Builds a hash representation containing simple objects, suitable for serialization (JSON). def as_json(_options = {}) {id: id, name: name, email: email, type: type, meta: meta} end end end end
Version data entries
13 entries across 13 versions & 1 rubygems