Module: ActiveAdmin::Annotations::ReviewAccess

Defined in:
lib/activeadmin/annotations/review_access.rb

Defined Under Namespace

Classes: Error, Forbidden, NotFound

Class Method Summary collapse

Class Method Details

.authorize_annotation!(annotation:, reviewer:) ⇒ Object

Raises:



21
22
23
24
25
26
27
# File 'lib/activeadmin/annotations/review_access.rb', line 21

def self.authorize_annotation!(annotation:, reviewer:)
  raise Forbidden, "Annotation not found" unless annotation
  raise Forbidden, "Annotation not found" unless reviewer.present? &&
    annotation.annotation_review.reviewer_id == reviewer.id

  annotation
end

.review_for_span_create!(review_id:, reviewer:) ⇒ Object

Raises:



11
12
13
14
15
16
17
18
19
# File 'lib/activeadmin/annotations/review_access.rb', line 11

def self.review_for_span_create!(review_id:, reviewer:)
  raise NotFound, "Review not found" if review_id.blank?

  review = Review.find_by(id: review_id)
  raise NotFound, "Review not found" unless review
  raise Forbidden, "Review not found" unless reviewer.present? && review.reviewer_id == reviewer.id

  review
end