debian-mirror-gitlab/app/models/concerns/bulk_member_access_load.rb

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

25 lines
907 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module BulkMemberAccessLoad
extend ActiveSupport::Concern
included do
2021-12-07 22:27:20 +05:30
def merge_value_to_request_store(resource_klass, resource_id, value)
2022-05-07 20:08:51 +05:30
Gitlab::SafeRequestLoader.execute(resource_key: max_member_access_for_resource_key(resource_klass),
resource_ids: [resource_id],
default_value: Gitlab::Access::NO_ACCESS) do
2021-04-29 21:17:54 +05:30
{ resource_id => value }
end
end
2022-07-16 23:28:13 +05:30
def purge_resource_id_from_request_store(resource_klass, resource_id)
Gitlab::SafeRequestPurger.execute(resource_key: max_member_access_for_resource_key(resource_klass),
resource_ids: [resource_id])
end
2022-05-07 20:08:51 +05:30
def max_member_access_for_resource_key(klass)
"max_member_access_for_#{klass.name.underscore.pluralize}:#{self.class}:#{self.id}"
2021-04-29 21:17:54 +05:30
end
2018-03-17 18:26:18 +05:30
end
end