<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Ability</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
        <h1>
            <span class="type">Class</span> 
            Ability 
            
                <span class="parent">&lt; 
                    
                    Object
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../files/app/models/ability_rb.html">app/models/ability.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-c-allowed">allowed</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>G</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-c-group_abilities">group_abilities</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>P</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-c-project_abilities">project_abilities</a>,
              </li>
            
              
              <li>
                <a href="#method-c-project_admin_rules">project_admin_rules</a>,
              </li>
            
              
              <li>
                <a href="#method-c-project_dev_rules">project_dev_rules</a>,
              </li>
            
              
              <li>
                <a href="#method-c-project_guest_rules">project_guest_rules</a>,
              </li>
            
              
              <li>
                <a href="#method-c-project_master_rules">project_master_rules</a>,
              </li>
            
              
              <li>
                <a href="#method-c-project_report_rules">project_report_rules</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-allowed">
            
              <b>allowed</b>(object, subject)
            
            <a href="../classes/Ability.html#method-c-allowed" name="method-c-allowed" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-allowed_source')" id="l_method-c-allowed_source">show</a>
                
              </p>
              <div id="method-c-allowed_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 3</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">allowed</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">subject</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;Project&quot;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">project_abilities</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;Issue&quot;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">issue_abilities</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;Note&quot;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">note_abilities</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;Snippet&quot;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">snippet_abilities</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;MergeRequest&quot;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">merge_request_abilities</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;Group&quot;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">group_abilities</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">subject</span>)
  <span class="ruby-keyword">else</span> []
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-group_abilities">
            
              <b>group_abilities</b>(user, group)
            
            <a href="../classes/Ability.html#method-c-group_abilities" name="method-c-group_abilities" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-group_abilities_source')" id="l_method-c-group_abilities_source">show</a>
                
              </p>
              <div id="method-c-group_abilities_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 107</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">group_abilities</span> <span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>
  <span class="ruby-identifier">rules</span> = []

  <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> [
    <span class="ruby-value">:manage_group</span>
  ] <span class="ruby-keyword">if</span> <span class="ruby-identifier">group</span>.<span class="ruby-identifier">owner</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">user</span>

  <span class="ruby-identifier">rules</span>.<span class="ruby-identifier">flatten</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-project_abilities">
            
              <b>project_abilities</b>(user, project)
            
            <a href="../classes/Ability.html#method-c-project_abilities" name="method-c-project_abilities" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-project_abilities_source')" id="l_method-c-project_abilities_source">show</a>
                
              </p>
              <div id="method-c-project_abilities_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">project_abilities</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">project</span>)
  <span class="ruby-identifier">rules</span> = []

  <span class="ruby-comment"># Rules based on role in project</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">master_access_for?</span>(<span class="ruby-identifier">user</span>)
    <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">project_master_rules</span>

  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">dev_access_for?</span>(<span class="ruby-identifier">user</span>)
    <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">project_dev_rules</span>

  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">report_access_for?</span>(<span class="ruby-identifier">user</span>)
    <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">project_report_rules</span>

  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">guest_access_for?</span>(<span class="ruby-identifier">user</span>)
    <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">project_guest_rules</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">namespace</span>
    <span class="ruby-comment"># If user own project namespace</span>
    <span class="ruby-comment"># (Ex. group owner or account owner)</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">owner</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">user</span>
      <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">project_admin_rules</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># For compatibility with global projects</span>
    <span class="ruby-comment"># use projects.owner_id</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">owner</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">user</span>
      <span class="ruby-identifier">rules</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">project_admin_rules</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>


  <span class="ruby-identifier">rules</span>.<span class="ruby-identifier">flatten</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-project_admin_rules">
            
              <b>project_admin_rules</b>()
            
            <a href="../classes/Ability.html#method-c-project_admin_rules" name="method-c-project_admin_rules" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-project_admin_rules_source')" id="l_method-c-project_admin_rules_source">show</a>
                
              </p>
              <div id="method-c-project_admin_rules_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 99</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">project_admin_rules</span>
  <span class="ruby-identifier">project_master_rules</span> <span class="ruby-operator">+</span> [
    <span class="ruby-value">:change_namespace</span>,
    <span class="ruby-value">:rename_project</span>,
    <span class="ruby-value">:remove_project</span>
  ]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-project_dev_rules">
            
              <b>project_dev_rules</b>()
            
            <a href="../classes/Ability.html#method-c-project_dev_rules" name="method-c-project_dev_rules" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-project_dev_rules_source')" id="l_method-c-project_dev_rules_source">show</a>
                
              </p>
              <div id="method-c-project_dev_rules_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 74</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">project_dev_rules</span>
  <span class="ruby-identifier">project_report_rules</span> <span class="ruby-operator">+</span> [
    <span class="ruby-value">:write_wiki</span>,
    <span class="ruby-value">:push_code</span>
  ]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-project_guest_rules">
            
              <b>project_guest_rules</b>()
            
            <a href="../classes/Ability.html#method-c-project_guest_rules" name="method-c-project_guest_rules" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-project_guest_rules_source')" id="l_method-c-project_guest_rules_source">show</a>
                
              </p>
              <div id="method-c-project_guest_rules_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 50</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">project_guest_rules</span>
  [
    <span class="ruby-value">:read_project</span>,
    <span class="ruby-value">:read_wiki</span>,
    <span class="ruby-value">:read_issue</span>,
    <span class="ruby-value">:read_milestone</span>,
    <span class="ruby-value">:read_snippet</span>,
    <span class="ruby-value">:read_team_member</span>,
    <span class="ruby-value">:read_merge_request</span>,
    <span class="ruby-value">:read_note</span>,
    <span class="ruby-value">:write_project</span>,
    <span class="ruby-value">:write_issue</span>,
    <span class="ruby-value">:write_note</span>
  ]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-project_master_rules">
            
              <b>project_master_rules</b>()
            
            <a href="../classes/Ability.html#method-c-project_master_rules" name="method-c-project_master_rules" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-project_master_rules_source')" id="l_method-c-project_master_rules_source">show</a>
                
              </p>
              <div id="method-c-project_master_rules_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 81</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">project_master_rules</span>
  <span class="ruby-identifier">project_dev_rules</span> <span class="ruby-operator">+</span> [
    <span class="ruby-value">:push_code_to_protected_branches</span>,
    <span class="ruby-value">:modify_issue</span>,
    <span class="ruby-value">:modify_snippet</span>,
    <span class="ruby-value">:modify_merge_request</span>,
    <span class="ruby-value">:admin_issue</span>,
    <span class="ruby-value">:admin_milestone</span>,
    <span class="ruby-value">:admin_snippet</span>,
    <span class="ruby-value">:admin_team_member</span>,
    <span class="ruby-value">:admin_merge_request</span>,
    <span class="ruby-value">:admin_note</span>,
    <span class="ruby-value">:accept_mr</span>,
    <span class="ruby-value">:admin_wiki</span>,
    <span class="ruby-value">:admin_project</span>
  ]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-project_report_rules">
            
              <b>project_report_rules</b>()
            
            <a href="../classes/Ability.html#method-c-project_report_rules" name="method-c-project_report_rules" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-project_report_rules_source')" id="l_method-c-project_report_rules_source">show</a>
                
              </p>
              <div id="method-c-project_report_rules_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/ability.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">project_report_rules</span>
  <span class="ruby-identifier">project_guest_rules</span> <span class="ruby-operator">+</span> [
    <span class="ruby-value">:download_code</span>,
    <span class="ruby-value">:write_merge_request</span>,
    <span class="ruby-value">:write_snippet</span>
  ]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                        </div>

    </div>
  </body>
</html>