gitlab-org--gitlab-foss/app/finders/resource_state_event_finder.rb

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

31 lines
624 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class ResourceStateEventFinder
include FinderMethods
def initialize(current_user, eventable)
@current_user = current_user
@eventable = eventable
end
def execute
return ResourceStateEvent.none unless can_read_eventable?
eventable.resource_state_events.includes(:user) # rubocop: disable CodeReuse/ActiveRecord
end
def can_read_eventable?
return unless eventable
Ability.allowed?(current_user, read_ability, eventable)
end
private
attr_reader :current_user, :eventable
def read_ability
:"read_#{eventable.class.to_ability_name}"
end
end