f694f94c49
This class can be used to reduce a list of issues down to a subset based on user permissions. This class operates in such a way that it can reduce issues using as few queries as possible, if any at all.
14 lines
278 B
Ruby
14 lines
278 B
Ruby
class IssuablePolicy < BasePolicy
|
|
def action_name
|
|
@subject.class.name.underscore
|
|
end
|
|
|
|
def rules
|
|
if @user && @subject.assignee_or_author?(@user)
|
|
can! :"read_#{action_name}"
|
|
can! :"update_#{action_name}"
|
|
end
|
|
|
|
delegate! @subject.project
|
|
end
|
|
end
|