Sha256: 7f7a0a092162c3b07d04592e76ff925bef0146e2d7254408738847e27eda818c

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

module Timber
  module Contexts
    # The session context tracks the current session for the given user.
    #
    # @note This is tracked automatically with the {Integrations::Rack::SessionContext} rack
    #   middleware.
    class Session < Context
      @keyspace = :session

      attr_reader :id

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

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