Class: Gitlab::WebHooks::RecursionDetection::UUID
- Inherits:
-
Object
- Object
- Gitlab::WebHooks::RecursionDetection::UUID
- Includes:
- Singleton
- Defined in:
- lib/gitlab/web_hooks/recursion_detection/uuid.rb
Constant Summary collapse
- HEADER =
"#{::Gitlab::WebHooks::GITLAB_EVENT_HEADER}-UUID"
Instance Attribute Summary collapse
-
#request_uuid ⇒ Object
Returns the value of attribute request_uuid.
Class Method Summary collapse
-
.instance ⇒ Object
Back the Singleton with RequestStore so it is isolated to this request.
Instance Method Summary collapse
- #header(hook) ⇒ Object
-
#initialize ⇒ UUID
constructor
A new instance of UUID.
-
#uuid_for_hook(hook) ⇒ Object
Returns a UUID, which will be either:.
Constructor Details
#initialize ⇒ UUID
Returns a new instance of UUID.
13 14 15 |
# File 'lib/gitlab/web_hooks/recursion_detection/uuid.rb', line 13 def initialize self.new_uuids_for_hooks = {} end |
Instance Attribute Details
#request_uuid ⇒ Object
Returns the value of attribute request_uuid.
11 12 13 |
# File 'lib/gitlab/web_hooks/recursion_detection/uuid.rb', line 11 def request_uuid @request_uuid end |
Class Method Details
.instance ⇒ Object
Back the Singleton with RequestStore so it is isolated to this request.
19 20 21 |
# File 'lib/gitlab/web_hooks/recursion_detection/uuid.rb', line 19 def instance Gitlab::SafeRequestStore[:web_hook_recursion_detection_uuid] ||= new end |
Instance Method Details
#header(hook) ⇒ Object
32 33 34 |
# File 'lib/gitlab/web_hooks/recursion_detection/uuid.rb', line 32 def header(hook) { HEADER => uuid_for_hook(hook) } end |
#uuid_for_hook(hook) ⇒ Object
Returns a UUID, which will be either:
- The UUID that was recycled from the request headers if the request was made by a webhook.
- A new UUID initialized for the webhook.
28 29 30 |
# File 'lib/gitlab/web_hooks/recursion_detection/uuid.rb', line 28 def uuid_for_hook(hook) request_uuid || new_uuid_for_hook(hook) end |