Sha256: 7dfc8b22370c1b02010f551ecb0ef5f89fb95beb72837de03e9d59509c17287f

Contents?: true

Size: 792 Bytes

Versions: 3

Compression:

Stored size: 792 Bytes

Contents

require "timber/context"
require "timber/util"

module Timber
  module Contexts
    # The system context tracks OS level process information, such as the process ID.
    #
    # @note This is tracked automatically in {CurrentContext}. When the current context
    #   is initialized, the system context gets added automatically.
    class System < Context
      @keyspace = :system

      attr_reader :hostname, :pid

      def initialize(attributes)
        @hostname = attributes[:hostname]
        @pid = attributes[:pid]
        @pid = @pid.to_s
      end

      # Builds a hash representation containing simple objects, suitable for serialization (JSON).
      def as_json(_options = {})
        {hostname: hostname, pid: Timber::Util::Object.try(pid, :to_s)}
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timber-2.1.1 lib/timber/contexts/system.rb
timber-2.1.0 lib/timber/contexts/system.rb
timber-2.1.0.rc6 lib/timber/contexts/system.rb