Sha256: a2ebf5a3848b8e22f49915dfe28de9d23ae04aabd6dd8e3440b1c3beb0aaa3e7

Contents?: true

Size: 424 Bytes

Versions: 2

Compression:

Stored size: 424 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'

module UU
  module LogContext
    attr_writer :context

    def context
      @context ||= {}
    end

    def append_context(context_)
      self.context = context.merge(context_)
    end

    def with(context_)
      original_context = context
      self.context = context.merge(context_)
      yield
    ensure
      self.context = original_context
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
uu-0.2.2 lib/uu/log_context.rb
uu-0.2.1 lib/uu/log_context.rb