Newer
Older
dmpopidor / html / Ability.html
@Marta Ribeiro Marta Ribeiro on 3 Jun 2016 12 KB DMPonline4 - RAILS 4.0 (#4)
<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<title>class Ability - DMPonline4 Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>app/models/ability.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link"><a href="Object.html">Object</a>
  
</nav>

    <!-- Included Modules -->
<nav id="includes-section" class="section">
  <h3 class="section-header">Included Modules</h3>

  <ul class="link-list">
  
  
    <li><span class="include">CanCan::Ability</span>
  
  
  </ul>
</nav>

    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-new">::new</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./README_rdoc.html">README</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./Settings.html">Settings</a>
  
    <li><a href="./Settings/Dmptemplate.html">Settings::Dmptemplate</a>
  
    <li><a href="./Settings/PlanList.html">Settings::PlanList</a>
  
    <li><a href="./Settings/PlansController.html">Settings::PlansController</a>
  
    <li><a href="./Settings/ProjectsController.html">Settings::ProjectsController</a>
  
    <li><a href="./Settings/SettingsController.html">Settings::SettingsController</a>
  
    <li><a href="./ActiveAdmin.html">ActiveAdmin</a>
  
    <li><a href="./ActiveAdmin/Views.html">ActiveAdmin::Views</a>
  
    <li><a href="./ActiveAdmin/Views/Pages.html">ActiveAdmin::Views::Pages</a>
  
    <li><a href="./ActiveAdmin/Views/Pages/Base.html">ActiveAdmin::Views::Pages::Base</a>
  
    <li><a href="./Users.html">Users</a>
  
    <li><a href="./Users/OmniauthCallbacksController.html">Users::OmniauthCallbacksController</a>
  
    <li><a href="./Users/OmniauthShibbolethRequestController.html">Users::OmniauthShibbolethRequestController</a>
  
    <li><a href="./DMPonline4.html">DMPonline4</a>
  
    <li><a href="./DMPonline4/Application.html">DMPonline4::Application</a>
  
    <li><a href="./Ability.html">Ability</a>
  
    <li><a href="./Answer.html">Answer</a>
  
    <li><a href="./AnswersController.html">AnswersController</a>
  
    <li><a href="./ApplicationController.html">ApplicationController</a>
  
    <li><a href="./ApplicationHelper.html">ApplicationHelper</a>
  
    <li><a href="./Comment.html">Comment</a>
  
    <li><a href="./CommentsController.html">CommentsController</a>
  
    <li><a href="./ConfirmationsController.html">ConfirmationsController</a>
  
    <li><a href="./ContactsController.html">ContactsController</a>
  
    <li><a href="./CustomFailure.html">CustomFailure</a>
  
    <li><a href="./Dmptemplate.html">Dmptemplate</a>
  
    <li><a href="./DmptemplatesController.html">DmptemplatesController</a>
  
    <li><a href="./ExistingUsersController.html">ExistingUsersController</a>
  
    <li><a href="./ExportedPlan.html">ExportedPlan</a>
  
    <li><a href="./FileType.html">FileType</a>
  
    <li><a href="./FileUpload.html">FileUpload</a>
  
    <li><a href="./Guidance.html">Guidance</a>
  
    <li><a href="./GuidanceGroup.html">GuidanceGroup</a>
  
    <li><a href="./GuidanceGroupsController.html">GuidanceGroupsController</a>
  
    <li><a href="./GuidancesController.html">GuidancesController</a>
  
    <li><a href="./HomeController.html">HomeController</a>
  
    <li><a href="./Object.html">Object</a>
  
    <li><a href="./Option.html">Option</a>
  
    <li><a href="./OptionWarning.html">OptionWarning</a>
  
    <li><a href="./Organisation.html">Organisation</a>
  
    <li><a href="./OrganisationType.html">OrganisationType</a>
  
    <li><a href="./OrganisationUsersController.html">OrganisationUsersController</a>
  
    <li><a href="./OrganisationsController.html">OrganisationsController</a>
  
    <li><a href="./PasswordsController.html">PasswordsController</a>
  
    <li><a href="./Phase.html">Phase</a>
  
    <li><a href="./Plan.html">Plan</a>
  
    <li><a href="./PlanSection.html">PlanSection</a>
  
    <li><a href="./PlansController.html">PlansController</a>
  
    <li><a href="./PlansHelper.html">PlansHelper</a>
  
    <li><a href="./Project.html">Project</a>
  
    <li><a href="./ProjectGroup.html">ProjectGroup</a>
  
    <li><a href="./ProjectGroupsController.html">ProjectGroupsController</a>
  
    <li><a href="./ProjectPartner.html">ProjectPartner</a>
  
    <li><a href="./ProjectsController.html">ProjectsController</a>
  
    <li><a href="./Question.html">Question</a>
  
    <li><a href="./QuestionFormat.html">QuestionFormat</a>
  
    <li><a href="./RegistrationsController.html">RegistrationsController</a>
  
    <li><a href="./Role.html">Role</a>
  
    <li><a href="./Section.html">Section</a>
  
    <li><a href="./SessionsController.html">SessionsController</a>
  
    <li><a href="./SplashLog.html">SplashLog</a>
  
    <li><a href="./SplashLogsController.html">SplashLogsController</a>
  
    <li><a href="./StaticPagesController.html">StaticPagesController</a>
  
    <li><a href="./SuggestedAnswer.html">SuggestedAnswer</a>
  
    <li><a href="./Theme.html">Theme</a>
  
    <li><a href="./ThemesController.html">ThemesController</a>
  
    <li><a href="./User.html">User</a>
  
    <li><a href="./UserMailer.html">UserMailer</a>
  
    <li><a href="./UserOrgRole.html">UserOrgRole</a>
  
    <li><a href="./UserOrgRolesController.html">UserOrgRolesController</a>
  
    <li><a href="./UserRoleType.html">UserRoleType</a>
  
    <li><a href="./UserRoleTypesController.html">UserRoleTypesController</a>
  
    <li><a href="./UserStatus.html">UserStatus</a>
  
    <li><a href="./UserStatusesController.html">UserStatusesController</a>
  
    <li><a href="./UserType.html">UserType</a>
  
    <li><a href="./UserTypesController.html">UserTypesController</a>
  
    <li><a href="./UsersController.html">UsersController</a>
  
    <li><a href="./Version.html">Version</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class Ability</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(user)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File app/models/ability.rb, line 4</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-comment"># Define abilities for the passed in user here. For example:
</span>
  <span class="ruby-comment">#
</span>
    <span class="ruby-identifier">user</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment"># guest user (not logged in)
</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">has_role?</span> <span class="ruby-value">:admin</span>
      <span class="ruby-identifier">can</span> <span class="ruby-value">:manage</span>, <span class="ruby-value">:all</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">can</span> <span class="ruby-value">:read</span>, <span class="ruby-value">:all</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">can</span> <span class="ruby-value">:manage_settings</span>, <span class="ruby-constant">User</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">viewed_user</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">viewed_user</span>.<span class="ruby-identifier">present?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">viewed_user</span>.<span class="ruby-identifier">id</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-comment">#
</span>
  <span class="ruby-comment"># The first argument to `can` is the action you are giving the user 
</span>
  <span class="ruby-comment"># permission to do.
</span>
  <span class="ruby-comment"># If you pass :manage it will apply to every action. Other common actions
</span>
  <span class="ruby-comment"># here are :read, :create, :update and :destroy.
</span>
  <span class="ruby-comment">#
</span>
  <span class="ruby-comment"># The second argument is the resource the user can perform the action on. 
</span>
  <span class="ruby-comment"># If you pass :all it will apply to every resource. Otherwise pass a Ruby
</span>
  <span class="ruby-comment"># class of the resource.
</span>
  <span class="ruby-comment">#
</span>
  <span class="ruby-comment"># The third argument is an optional hash of conditions to further filter the
</span>
  <span class="ruby-comment"># objects.
</span>
  <span class="ruby-comment"># For example, here the user can only update published articles.
</span>
  <span class="ruby-comment">#
</span>
  <span class="ruby-comment">#   can :update, Article, :published =&gt; true
</span>
  <span class="ruby-comment">#
</span>
  <span class="ruby-comment"># See the wiki for details:
</span>
  <span class="ruby-comment"># https://github.com/ryanb/cancan/wiki/Defining-Abilities
</span>
 
<span class="ruby-keyword">end</span></pre>
          </div><!-- new-source -->
          
        </div>

        

        
      </div><!-- new-method -->

    
    </section><!-- public-class-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.2.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>