Sha256: c404e0f1d27a0bd3d7887a35df529320f3263f1cb0858ad3b1d9ea85daf39005

Contents?: true

Size: 767 Bytes

Versions: 13

Compression:

Stored size: 767 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 = Timber::Util::Object.try(attributes[:pid], :to_i)
      end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
timber-2.5.1 lib/timber/contexts/system.rb
timber-2.5.0 lib/timber/contexts/system.rb
timber-2.4.0 lib/timber/contexts/system.rb
timber-2.3.4 lib/timber/contexts/system.rb
timber-2.3.3 lib/timber/contexts/system.rb
timber-2.3.2 lib/timber/contexts/system.rb
timber-2.3.1 lib/timber/contexts/system.rb
timber-2.3.0 lib/timber/contexts/system.rb
timber-2.2.3 lib/timber/contexts/system.rb
timber-2.2.2 lib/timber/contexts/system.rb
timber-2.2.1 lib/timber/contexts/system.rb
timber-2.2.0 lib/timber/contexts/system.rb
timber-2.1.10 lib/timber/contexts/system.rb