Sha256: 13716cc85674cc12008d08df2a006cc39bb0b08ba2d4f4d7fede54014bdf0366

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 Bytes

Contents

module Timber
  module Contexts
    # The user context tracks the currently authenticated user.
    #
    # @note This is tracked automatically with the {Integrations::Rack::UserContext} rack
    #   middleware.
    class User < Context
      @keyspace = :user

      attr_reader :id, :name, :email

      def initialize(attributes)
        @id = attributes[:id]
        @name = attributes[:name]
        @email = attributes[:email]
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/contexts/user.rb
timber-2.0.23 lib/timber/contexts/user.rb