Sha256: 8690ee82849e1873f15dbf3c084332031a6ed182187b78fff750a89e0215049f

Contents?: true

Size: 582 Bytes

Versions: 4

Compression:

Stored size: 582 Bytes

Contents

# frozen_string_literal: true

module Loggery
  module Metadata
    module Store
      METADATA_KEY = :logging_metadata

      def self.store
        Thread.current[METADATA_KEY]
      end

      def self.with_metadata(metadata)
        init_store
        merge!(metadata)
        yield
      ensure
        close_store
      end

      def self.merge!(metadata)
        store.merge!(metadata)
      end

      def self.init_store
        Thread.current[METADATA_KEY] = {}
      end

      def self.close_store
        Thread.current[METADATA_KEY] = nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loggery-0.3.0 lib/loggery/metadata/store.rb
loggery-0.2.1 lib/loggery/metadata/store.rb
loggery-0.2.0 lib/loggery/metadata/store.rb
loggery-0.1.0 lib/loggery/metadata/store.rb