KatanaCode/blogit

View on GitHub
doc/Blogit/Post.html

Summary

Maintainability
Test Coverage
<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Blogit::Post
  
    &mdash; Blogit - Add a blog to your Ruby on Rails application
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!Blogit/Post.html";
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (P)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Blogit.html" title="Blogit (module)">Blogit</a></span></span>
     &raquo; 
    <span class="title">Post</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Blogit::Post
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">ActiveRecord::Base</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">ActiveRecord::Base</li>
          
            <li class="next">Blogit::Post</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">app/models/blogit/post.rb</dd>
  
</dl>
<div class="clear"></div>








  
    <h2>
      Class Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#active_with_id-class_method" title="active_with_id (class method)">+ (Object) <strong>active_with_id</strong>(id) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Finds an active post with given id.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#for_feed-class_method" title="for_feed (class method)">+ (Object) <strong>for_feed</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The posts to be displayed for RSS and XML feeds/sitemaps.</p>
</div></span>
  
</li>

      
    </ul>
  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#blogger-instance_method" title="#blogger (instance method)">- (Object) <strong>blogger</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The blogger (User, Admin, etc.) who wrote this Post.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#blogger_display_name-instance_method" title="#blogger_display_name (instance method)">- (Object) <strong>blogger_display_name</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The blogger who wrote this <span class='object_link'><a href="" title="Blogit::Post (class)">Post&#39;s</a></span> display name.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#blogger_twitter_username-instance_method" title="#blogger_twitter_username (instance method)">- (Object) <strong>blogger_twitter_username</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>If there&#39;s a blogger and that blogger responds to :twitter_username, returns that.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#comments-instance_method" title="#comments (instance method)">- (Object) <strong>comments</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The <span class='object_link'><a href="Comment.html" title="Blogit::Comment (class)">Comments</a></span> written on this Post.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#comments%3D-instance_method" title="#comments= (instance method)">- (Object) <strong>comments=</strong>(value) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#published_at-instance_method" title="#published_at (instance method)">- (Object) <strong>published_at</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>TODO: Get published at working properly!.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#short_body-instance_method" title="#short_body (instance method)">- (Object) <strong>short_body</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The content of the Post to be shown in the RSS feed.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_param-instance_method" title="#to_param (instance method)">- (Object) <strong>to_param</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
    </ul>
  


  

  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="active_with_id-class_method">
  
    + (<tt>Object</tt>) <strong>active_with_id</strong>(id) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Finds an active post with given id</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>id</span>
      
      
        <span class='type'></span>
      
      
      
        &mdash;
        <div class='inline'><p>The id of the Post to find</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>a Blogit::Post</p>
</div>
      
    </li>
  
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>ActiveRecord::NoMethodError if no Blogit::Post could be found</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


64
65
66</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 64</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_active_with_id'>active_with_id</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_active'>active</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="for_feed-class_method">
  
    + (<tt>Object</tt>) <strong>for_feed</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The posts to be displayed for RSS and XML feeds/sitemaps</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>an ActiveRecord::Relation</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


54
55
56</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 54</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_for_feed'>for_feed</span>
  <span class='id identifier rubyid_active'>active</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>created_at DESC</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="blogger-instance_method">
  
    - (<tt>Object</tt>) <strong>blogger</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The blogger (User, Admin, etc.) who wrote this Post</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>a Blogger (polymorphic type)</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


33</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 33</span>

<span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='symbol'>:blogger</span><span class='comma'>,</span> <span class='symbol'>:polymorphic</span> <span class='op'>=&gt;</span> <span class='kw'>true</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="blogger_display_name-instance_method">
  
    - (<tt>Object</tt>) <strong>blogger_display_name</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The blogger who wrote this <span class='object_link'><a href="" title="Blogit::Post (class)">Post&#39;s</a></span> display name</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>the blogger&#39;s display name as a String if it&#39;s set.</p>
</div>
      
    </li>
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>an empty String if blogger is not present.</p>
</div>
      
    </li>
  
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>a ConfigurationError if the method called is not defined on <span class='object_link'><a href="#blogger-instance_method" title="Blogit::Post#blogger (method)">#blogger</a></span></p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


109
110
111
112
113
114
115
116
117</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 109</span>

<span class='kw'>def</span> <span class='id identifier rubyid_blogger_display_name'>blogger_display_name</span>
  <span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_blogger'>blogger</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_blogger'>blogger</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='const'>Blogit</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_blogger_display_name_method'>blogger_display_name_method</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_blogger'>blogger</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='const'>Blogit</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_blogger_display_name_method'>blogger_display_name_method</span><span class='rparen'>)</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='const'>Blogit</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_blogger_display_name_method'>blogger_display_name_method</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ConfigurationError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_blogger'>blogger</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_content'>#</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not defined</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="blogger_twitter_username-instance_method">
  
    - (<tt>Object</tt>) <strong>blogger_twitter_username</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>If there&#39;s a blogger and that blogger responds to :twitter_username, returns that.
Otherwise, returns nil</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


121
122
123
124
125</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 121</span>

<span class='kw'>def</span> <span class='id identifier rubyid_blogger_twitter_username'>blogger_twitter_username</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_blogger'>blogger</span> <span class='kw'>and</span> <span class='id identifier rubyid_blogger'>blogger</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:twitter_username</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_blogger'>blogger</span><span class='period'>.</span><span class='id identifier rubyid_twitter_username'>twitter_username</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="comments-instance_method">
  
    - (<tt>Object</tt>) <strong>comments</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The <span class='object_link'><a href="Comment.html" title="Blogit::Comment (class)">Comments</a></span> written on this Post</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>an ActiveRecord::Relation instance</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


39</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 39</span>

<span class='id identifier rubyid_has_many'>has_many</span> <span class='symbol'>:comments</span><span class='comma'>,</span> <span class='symbol'>:class_name</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Blogit::Comment</span><span class='tstring_end'>&quot;</span></span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="comments=-instance_method">
  
    - (<tt>Object</tt>) <strong>comments=</strong>(value) 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


98
99
100
101</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 98</span>

<span class='kw'>def</span> <span class='id identifier rubyid_comments='>comments=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_check_comments_config'>check_comments_config</span>
  <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="published_at-instance_method">
  
    - (<tt>Object</tt>) <strong>published_at</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>TODO: Get published at working properly!</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


73
74
75</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 73</span>

<span class='kw'>def</span> <span class='id identifier rubyid_published_at'>published_at</span>
  <span class='id identifier rubyid_created_at'>created_at</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="short_body-instance_method">
  
    - (<tt>Object</tt>) <strong>short_body</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The content of the Post to be shown in the RSS feed.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>description when Blogit.configuration.show_post_description is true</p>
</div>
      
    </li>
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>body when Blogit.configuration.show_post_description is false</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


85
86
87
88
89
90
91</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 85</span>

<span class='kw'>def</span> <span class='id identifier rubyid_short_body'>short_body</span>
  <span class='kw'>if</span> <span class='const'>Blogit</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_show_post_description'>show_post_description</span>
    <span class='id identifier rubyid_description'>description</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_body'>body</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="to_param-instance_method">
  
    - (<tt>Object</tt>) <strong>to_param</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


77
78
79</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/blogit/post.rb', line 77</span>

<span class='kw'>def</span> <span class='id identifier rubyid_to_param'>to_param</span>
  <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_title'>title</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Sat Oct 24 19:04:45 2015 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.6 (ruby-2.2.0).
</div>

  </body>
</html>