landline/doc/Hyde/Handlers/Handler.html

597 lines
16 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: Hyde::Handlers::Handler
&mdash; Documentation by YARD 0.9.34
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Hyde::Handlers::Handler";
relpath = '../../';
</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 class="nav_wrap">
<iframe id="nav" src="../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (H)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Hyde.html" title="Hyde (module)">Hyde</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Handlers.html" title="Hyde::Handlers (module)">Handlers</a></span></span>
&raquo;
<span class="title">Handler</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: Hyde::Handlers::Handler
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName"><span class='object_link'><a href="../Probe.html" title="Hyde::Probe (class)">Probe</a></span></span>
<ul class="fullTree">
<li>Object</li>
<li class="next"><span class='object_link'><a href="../Node.html" title="Hyde::Node (class)">Node</a></span></li>
<li class="next"><span class='object_link'><a href="../Probe.html" title="Hyde::Probe (class)">Probe</a></span></li>
<li class="next">Hyde::Handlers::Handler</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/hyde/probe/handler.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Probe that executes a callback on request</p>
</div>
</div>
<div class="tags">
</div><div id="subclasses">
<h2>Direct Known Subclasses</h2>
<p class="children"><span class='object_link'><a href="GET.html" title="Hyde::Handlers::GET (class)">GET</a></span></p>
</div>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#request-instance_method" title="#request (instance method)">#<strong>request</strong> &#x21d2; Object </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute request.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#response-instance_method" title="#response (instance method)">#<strong>response</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute response.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="../Probe.html" title="Hyde::Probe (class)">Probe</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../Probe.html#properties-instance_method" title="Hyde::Probe#properties (method)">#properties</a></span></p>
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="../Node.html" title="Hyde::Node (class)">Node</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../Node.html#remap-instance_method" title="Hyde::Node#remap (method)">#remap</a></span>, <span class='object_link'><a href="../Node.html#root-instance_method" title="Hyde::Node#root (method)">#root</a></span></p>
<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)">#<strong>initialize</strong>(path, parent:, &amp;exec) &#x21d2; Handler </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'><p>A new instance of Handler.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#process-instance_method" title="#process (instance method)">#<strong>process</strong>(request) &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Method callback on successful request navigation.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="../Node.html" title="Hyde::Node (class)">Node</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../Node.html#go-instance_method" title="Hyde::Node#go (method)">#go</a></span>, <span class='object_link'><a href="../Node.html#reject-instance_method" title="Hyde::Node#reject (method)">#reject</a></span></p>
<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">
#<strong>initialize</strong>(path, parent:, &amp;exec) &#x21d2; <tt><span class='object_link'><a href="" title="Hyde::Handlers::Handler (class)">Handler</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of Handler.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>Object</tt>)</span>
</li>
<li>
<span class='name'>parent</span>
<span class='type'>(<tt><span class='object_link'><a href="../Node.html" title="Hyde::Node (class)">Hyde::Node</a></span></tt>)</span>
</li>
<li>
<span class='name'>exec</span>
<span class='type'>(<tt>#call</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
12
13
14
15
16
17</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/hyde/probe/handler.rb', line 12</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>parent:</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_exec'>exec</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>parent:</span> <span class='id identifier rubyid_parent'>parent</span><span class='rparen'>)</span>
<span class='ivar'>@callback</span> <span class='op'>=</span> <span class='id identifier rubyid_exec'>exec</span>
<span class='ivar'>@context</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Hyde.html" title="Hyde (module)">Hyde</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../ProbeContext.html" title="Hyde::ProbeContext (class)">ProbeContext</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../ProbeContext.html#initialize-instance_method" title="Hyde::ProbeContext#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
<span class='ivar'>@response</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id=""></span>
<div class="method_details first">
<h3 class="signature first" id="request-instance_method">
#<strong>request</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute request.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
20
21
22</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/hyde/probe/handler.rb', line 20</span>
<span class='kw'>def</span> <span class='id identifier rubyid_request'>request</span>
<span class='ivar'>@request</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="response=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="response-instance_method">
#<strong>response</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute response.</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/hyde/probe/handler.rb', line 19</span>
<span class='kw'>def</span> <span class='id identifier rubyid_response'>response</span>
<span class='ivar'>@response</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="process-instance_method">
#<strong>process</strong>(request) &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Method callback on successful request navigation.
Runs block supplied with object initialization.
Request&#39;s #splat and #param are passed to block.</p>
<p>Callback&#39;s returned should be one of viable responses:</p>
<ul>
<li><span class='object_link'><a href="../Response.html" title="Hyde::Response (class)">Response</a></span> object</li>
<li>An array that matches Rack return form</li>
<li>An array that matches old (Rack 2.x) return form</li>
<li>A string (returned as HTML with code 200)</li>
<li>false (bounces the request to next handler)</li>
</ul>
</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="Hyde::Request (class)">Hyde::Request</a></span></tt>)</span>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
&mdash;
<div class='inline'><p>true if further navigation is possible</p>
</div>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>UncaughtThrowError</tt>)</span>
&mdash;
<div class='inline'><p>may raise if die() is called.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/hyde/probe/handler.rb', line 36</span>
<span class='kw'>def</span> <span class='id identifier rubyid_process'>process</span><span class='lparen'>(</span><span class='id identifier rubyid_request'>request</span><span class='rparen'>)</span>
<span class='ivar'>@response</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='kw'>return</span> <span class='id identifier rubyid_reject'>reject</span><span class='lparen'>(</span><span class='id identifier rubyid_request'>request</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\/?$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
<span class='ivar'>@request</span> <span class='op'>=</span> <span class='id identifier rubyid_request'>request</span>
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:break</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='ivar'>@context</span><span class='period'>.</span><span class='id identifier rubyid_instance_exec'>instance_exec</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_splat'>splat</span><span class='comma'>,</span>
<span class='op'>**</span><span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_param'>param</span><span class='comma'>,</span>
<span class='op'>&amp;</span><span class='ivar'>@callback</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_response'>response</span>
<span class='kw'>if</span> <span class='ivar'>@response</span> <span class='kw'>and</span> <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>File</span><span class='comma'>,</span> <span class='const'>IO</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span>
<span class='ivar'>@response</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span>
<span class='id identifier rubyid_throw'>throw</span> <span class='symbol'>:finish</span><span class='comma'>,</span> <span class='ivar'>@response</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_throw'>throw</span> <span class='symbol'>:finish</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Sun Sep 17 00:23:46 2023 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.34 (ruby-3.0.6).
</div>
</div>
</body>
</html>