debian-mirror-gitlab/lib/gitlab/with_request_store.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
525 B
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
module Gitlab
module WithRequestStore
2020-05-24 23:13:21 +05:30
def with_request_store(&block)
# Skip enabling the request store if it was already active. Whatever
# instantiated the request store first is responsible for clearing it
return yield if RequestStore.active?
enabling_request_store(&block)
end
private
def enabling_request_store
2020-04-08 14:13:33 +05:30
RequestStore.begin!
yield
ensure
RequestStore.end!
RequestStore.clear!
end
2020-05-24 23:13:21 +05:30
extend self
2020-04-08 14:13:33 +05:30
end
end