0
0
zero/doc/Zero/Controller.html
2012-11-26 21:45:33 +01:00

616 lines
13 KiB
HTML

<!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: Zero::Controller
&mdash; Documentation by YARD 0.8.3
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
hasFrames = window.top.frames.main ? true : false;
relpath = '../';
framesUrl = "../frames.html#!" + escape(window.location.href);
</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 (C)</a> &raquo;
<span class='title'><span class='object_link'><a href="../Zero.html" title="Zero (module)">Zero</a></span></span>
&raquo;
<span class="title">Controller</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: Zero::Controller
</h1>
<dl class="box">
<dt class="r1">Inherits:</dt>
<dd class="r1">
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">Zero::Controller</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">lib/zero/controller.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>abstract class to make creation of controllers easier</p>
<p>This abstract class creates an interface to make it easier to write rack
compatible controllers. It catches #call and creates a new instance with
the environment and calls #render on it.</p>
</div>
</div>
<div class="tags">
</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="#call-class_method" title="call (class method)">+ (Object) <strong>call</strong>(env) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>initialize a new instance of the controller and call response on it.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#renderer-class_method" title="renderer (class method)">+ (Object) <strong>renderer</strong> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>get the renderer set in the controller.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#renderer%3D-class_method" title="renderer= (class method)">+ (Object) <strong>renderer=</strong>(renderer) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>set the renderer to use in the controller.</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="#initialize-instance_method" title="#initialize (instance method)">- (Controller) <strong>initialize</strong>(request) </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'>
<p>initialize the controller.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#renderer-instance_method" title="#renderer (instance method)">- (Object) <strong>renderer</strong> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>a small helper to get the actual renderer.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#response-instance_method" title="#response (instance method)">- (Object) <strong>response</strong> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>build the response and return it.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
- (<tt><span class='object_link'><a href="" title="Zero::Controller (class)">Controller</a></span></tt>) <strong>initialize</strong>(request)
</h3><div class="docstring">
<div class="discussion">
<p>initialize the controller</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>request</span>
<span class='type'>(<tt><span class='object_link'><a href="Request.html" title="Zero::Request (class)">Request</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>a request object</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
30
31
32
33</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/zero/controller.rb', line 30</span>
<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_request identifier id'>request</span><span class='rparen token'>)</span>
<span class='rubyid_@request ivar id'>@request</span> <span class='assign token'>=</span> <span class='rubyid_request identifier id'>request</span>
<span class='rubyid_@response ivar id'>@response</span> <span class='assign token'>=</span> <span class='rubyid_Zero constant id'>Zero</span><span class='colon2 op'>::</span><span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span>
<span class='rubyid_end end kw'>end</span>
</pre>
</td>
</tr>
</table>
</div>
</div>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="call-class_method">
+ (<tt>Object</tt>) <strong>call</strong>(env)
</h3><div class="docstring">
<div class="discussion">
<p>initialize a new instance of the controller and call response on it</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
9
10
11</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/zero/controller.rb', line 9</span>
<span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_call identifier id'>call</span><span class='lparen token'>(</span><span class='rubyid_env identifier id'>env</span><span class='rparen token'>)</span>
<span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_Zero constant id'>Zero</span><span class='colon2 op'>::</span><span class='rubyid_Request constant id'>Request</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_env identifier id'>env</span><span class='rparen token'>)</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_response identifier id'>response</span>
<span class='rubyid_end end kw'>end</span>
</pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="renderer-class_method">
+ (<tt>Object</tt>) <strong>renderer</strong>
</h3><div class="docstring">
<div class="discussion">
<p>get the renderer set in the controller</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
19
20
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/zero/controller.rb', line 19</span>
<span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_renderer identifier id'>renderer</span>
<span class='rubyid_@@renderer ivar id'>@@renderer</span>
<span class='rubyid_end end kw'>end</span>
</pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="renderer=-class_method">
+ (<tt>Object</tt>) <strong>renderer=</strong>(renderer)
</h3><div class="docstring">
<div class="discussion">
<p>set the renderer to use in the controller</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
14
15
16</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/zero/controller.rb', line 14</span>
<span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_renderer identifier id'>renderer</span><span class='assign token'>=</span><span class='lparen token'>(</span><span class='rubyid_renderer identifier id'>renderer</span><span class='rparen token'>)</span>
<span class='rubyid_@@renderer ivar id'>@@renderer</span> <span class='assign token'>=</span> <span class='rubyid_renderer identifier id'>renderer</span>
<span class='rubyid_end end 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="renderer-instance_method">
- (<tt>Object</tt>) <strong>renderer</strong>
</h3><div class="docstring">
<div class="discussion">
<p>a small helper to get the actual renderer</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/zero/controller.rb', line 24</span>
<span class='rubyid_def def kw'>def</span> <span class='rubyid_renderer identifier id'>renderer</span>
<span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_class identifier id'>class</span><span class='dot token'>.</span><span class='rubyid_renderer identifier id'>renderer</span>
<span class='rubyid_end end kw'>end</span>
</pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="response-instance_method">
- (<tt>Object</tt>) <strong>response</strong>
</h3><div class="docstring">
<div class="discussion">
<p>build the response and return it</p>
<p>This method calls #process if it was defined so make it easier to process
the request before rendering stuff.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'></span>
<div class='inline'>
<p>Response a rack conform response</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
40
41
42
43
44</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/zero/controller.rb', line 40</span>
<span class='rubyid_def def kw'>def</span> <span class='rubyid_response identifier id'>response</span>
<span class='rubyid_process identifier id'>process</span> <span class='rubyid_if if_mod kw'>if</span> <span class='rubyid_respond_to? fid id'>respond_to?</span><span class='lparen token'>(</span><span class='symbol val'>:process</span><span class='rparen token'>)</span>
<span class='rubyid_render identifier id'>render</span>
<span class='rubyid_@response ivar id'>@response</span><span class='dot token'>.</span><span class='rubyid_to_a identifier id'>to_a</span>
<span class='rubyid_end end kw'>end</span>
</pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Nov 26 21:45:20 2012 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.8.3 (ruby-1.9.3).
</div>
</body>
</html>