Sha256: 8a8c7a7d8550411b7696be7a069f2f0ae8ad72c450acc1955a4929ab9ccc1d1e

Contents?: true

Size: 820 Bytes

Versions: 8

Compression:

Stored size: 820 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 = Timber::Util::Object.try(@pid, :to_i)
      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_i)}
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
timber-2.1.9 lib/timber/contexts/system.rb
timber-2.1.8 lib/timber/contexts/system.rb
timber-2.1.7 lib/timber/contexts/system.rb
timber-2.1.6 lib/timber/contexts/system.rb
timber-2.1.5 lib/timber/contexts/system.rb
timber-2.1.4 lib/timber/contexts/system.rb
timber-2.1.3 lib/timber/contexts/system.rb
timber-2.1.2 lib/timber/contexts/system.rb