# class Ability

### Public Class Methods

allowed(object, subject) click to toggle source

    # File app/models/ability.rb, line 3
    def allowed(object, subject)
      case subject.class.name
      when "Project" then project_abilities(object, subject)
      when "Issue" then issue_abilities(object, subject)
      when "Note" then note_abilities(object, subject)
      when "Snippet" then snippet_abilities(object, subject)
      when "MergeRequest" then merge_request_abilities(object, subject)
      else []
      end
    end

project_abilities(user, project) click to toggle source

    # File app/models/ability.rb, line 14
    def project_abilities(user, project)
      rules = []

      rules << [
        :read_project,
        :read_wiki,
        :read_issue,
        :read_milestone,
        :read_snippet,
        :read_team_member,
        :read_merge_request,
        :read_note,
        :write_project,
        :write_issue,
        :write_note
      ] if project.guest_access_for?(user)

      rules << [
        :download_code,
        :write_merge_request,
        :write_snippet
      ] if project.report_access_for?(user)

      rules << [
        :write_wiki,
        :push_code
      ] if project.dev_access_for?(user)

      rules << [
        :push_code_to_protected_branches
      ] if project.master_access_for?(user)

      rules << [
        :modify_issue,
        :modify_snippet,
        :modify_merge_request,
        :admin_project,
        :admin_issue,
        :admin_milestone,
        :admin_snippet,
        :admin_team_member,
        :admin_merge_request,
        :admin_note,
        :accept_mr,
        :admin_wiki
      ] if project.master_access_for?(user) || project.owner == user

      rules.flatten
    end