gitlabhq/doc/code/classes/NoteObserver.html

290 lines
11 KiB
HTML
Raw Normal View History

<?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>NoteObserver</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>
NoteObserver
<span class="parent">&lt;
ActiveRecord::Observer
</span>
</h1>
<ul class="files">
<li><a href="../files/app/observers/note_observer_rb.html">app/observers/note_observer.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-i-after_create">after_create</a>
</li>
</ul>
</dd>
<dt>N</dt>
<dd>
<ul>
<li>
<a href="#method-i-notify_team">notify_team</a>
</li>
</ul>
</dd>
<dt>S</dt>
<dd>
<ul>
<li>
<a href="#method-i-send_notify_mails">send_notify_mails</a>
</li>
</ul>
</dd>
<dt>T</dt>
<dd>
<ul>
<li>
<a href="#method-i-team_without_note_author">team_without_note_author</a>
</li>
</ul>
</dd>
</dl>
<!-- Methods -->
<div class="sectiontitle">Instance Public methods</div>
<div class="method">
<div class="title method-title" id="method-i-after_create">
<b>after_create</b>(note)
<a href="../classes/NoteObserver.html#method-i-after_create" name="method-i-after_create" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-after_create_source')" id="l_method-i-after_create_source">show</a>
</p>
<div id="method-i-after_create_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/observers/note_observer.rb, line 3</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">after_create</span>(<span class="ruby-identifier">note</span>)
<span class="ruby-identifier">send_notify_mails</span>(<span class="ruby-identifier">note</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="sectiontitle">Instance Protected methods</div>
<div class="method">
<div class="title method-title" id="method-i-notify_team">
<b>notify_team</b>(note)
<a href="../classes/NoteObserver.html#method-i-notify_team" name="method-i-notify_team" class="permalink">Link</a>
</div>
<div class="description">
<p>Notifies the whole team except the author of note</p>
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-notify_team_source')" id="l_method-i-notify_team_source">show</a>
</p>
<div id="method-i-notify_team_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/observers/note_observer.rb, line 22</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">notify_team</span>(<span class="ruby-identifier">note</span>)
<span class="ruby-comment"># Note: wall posts are not &quot;attached&quot; to anything, so fall back to &quot;Wall&quot;</span>
<span class="ruby-identifier">noteable_type</span> = <span class="ruby-identifier">note</span>.<span class="ruby-identifier">noteable_type</span>.<span class="ruby-identifier">presence</span> <span class="ruby-operator">||</span> <span class="ruby-string">&quot;Wall&quot;</span>
<span class="ruby-identifier">notify_method</span> = <span class="ruby-node">&quot;note_#{noteable_type.underscore}_email&quot;</span>.<span class="ruby-identifier">to_sym</span>
<span class="ruby-keyword">if</span> <span class="ruby-constant">Notify</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">notify_method</span>
<span class="ruby-identifier">team_without_note_author</span>(<span class="ruby-identifier">note</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span>
<span class="ruby-constant">Notify</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">notify_method</span>, <span class="ruby-identifier">u</span>.<span class="ruby-identifier">id</span>, <span class="ruby-identifier">note</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">deliver</span>
<span class="ruby-keyword">end</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-i-send_notify_mails">
<b>send_notify_mails</b>(note)
<a href="../classes/NoteObserver.html#method-i-send_notify_mails" name="method-i-send_notify_mails" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-send_notify_mails_source')" id="l_method-i-send_notify_mails_source">show</a>
</p>
<div id="method-i-send_notify_mails_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/observers/note_observer.rb, line 9</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">send_notify_mails</span>(<span class="ruby-identifier">note</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">note</span>.<span class="ruby-identifier">notify</span>
<span class="ruby-identifier">notify_team</span>(<span class="ruby-identifier">note</span>)
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">note</span>.<span class="ruby-identifier">notify_author</span>
<span class="ruby-comment"># Notify only author of resource</span>
<span class="ruby-constant">Notify</span>.<span class="ruby-identifier">note_commit_email</span>(<span class="ruby-identifier">note</span>.<span class="ruby-identifier">commit_author</span>.<span class="ruby-identifier">id</span>, <span class="ruby-identifier">note</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">deliver</span>
<span class="ruby-keyword">else</span>
<span class="ruby-comment"># Otherwise ignore it</span>
<span class="ruby-keyword">nil</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-i-team_without_note_author">
<b>team_without_note_author</b>(note)
<a href="../classes/NoteObserver.html#method-i-team_without_note_author" name="method-i-team_without_note_author" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-team_without_note_author_source')" id="l_method-i-team_without_note_author_source">show</a>
</p>
<div id="method-i-team_without_note_author_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/observers/note_observer.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">team_without_note_author</span>(<span class="ruby-identifier">note</span>)
<span class="ruby-identifier">note</span>.<span class="ruby-identifier">project</span>.<span class="ruby-identifier">users</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">note</span>.<span class="ruby-identifier">author</span>.<span class="ruby-identifier">id</span> }
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>