299 lines
11 KiB
HTML
299 lines
11 KiB
HTML
|
<?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>Class: Rack::Utils::Context</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
||
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
||
|
<script type="text/javascript">
|
||
|
// <![CDATA[
|
||
|
|
||
|
function popupCode( url ) {
|
||
|
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
||
|
}
|
||
|
|
||
|
function toggleCode( id ) {
|
||
|
if ( document.getElementById )
|
||
|
elem = document.getElementById( id );
|
||
|
else if ( document.all )
|
||
|
elem = eval( "document.all." + id );
|
||
|
else
|
||
|
return false;
|
||
|
|
||
|
elemStyle = elem.style;
|
||
|
|
||
|
if ( elemStyle.display != "block" ) {
|
||
|
elemStyle.display = "block"
|
||
|
} else {
|
||
|
elemStyle.display = "none"
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
// Make codeblocks hidden by default
|
||
|
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
||
|
|
||
|
// ]]>
|
||
|
</script>
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
|
||
|
|
||
|
<div id="classHeader">
|
||
|
<table class="header-table">
|
||
|
<tr class="top-aligned-row">
|
||
|
<td><strong>Class</strong></td>
|
||
|
<td class="class-name-in-header">Rack::Utils::Context</td>
|
||
|
</tr>
|
||
|
<tr class="top-aligned-row">
|
||
|
<td><strong>In:</strong></td>
|
||
|
<td>
|
||
|
<a href="../../../files/lib/rack/utils_rb.html">
|
||
|
lib/rack/utils.rb
|
||
|
</a>
|
||
|
<br />
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr class="top-aligned-row">
|
||
|
<td><strong>Parent:</strong></td>
|
||
|
<td>
|
||
|
Proc
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<!-- banner header -->
|
||
|
|
||
|
<div id="bodyContent">
|
||
|
|
||
|
|
||
|
|
||
|
<div id="contextContent">
|
||
|
|
||
|
<div id="description">
|
||
|
<p>
|
||
|
The recommended manner in which to implement a contexting application is to
|
||
|
define a method <a href="Context.html#M000031">context</a> in which a <a
|
||
|
href="Context.html#M000029">new</a> <a href="Context.html">Context</a> is
|
||
|
instantiated.
|
||
|
</p>
|
||
|
<p>
|
||
|
As a <a href="Context.html">Context</a> is a glorified block, it is highly
|
||
|
recommended that you define the contextual block within the
|
||
|
application‘s operational scope. This would typically the application
|
||
|
as you‘re place into <a href="../../Rack.html">Rack</a>‘s
|
||
|
stack.
|
||
|
</p>
|
||
|
<pre>
|
||
|
class MyObject
|
||
|
...
|
||
|
def context app
|
||
|
Rack::Utils::Context.new app do |env|
|
||
|
do_stuff
|
||
|
response = app.call(env)
|
||
|
do_more_stuff
|
||
|
end
|
||
|
end
|
||
|
...
|
||
|
end
|
||
|
</pre>
|
||
|
<p>
|
||
|
mobj = MyObject.new app = mobj.context other_app Rack::Handler::Mongrel.new
|
||
|
app
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div id="method-list">
|
||
|
<h3 class="section-bar">Methods</h3>
|
||
|
|
||
|
<div class="name-list">
|
||
|
<a href="#M000031">context</a>
|
||
|
<a href="#M000030">inspect</a>
|
||
|
<a href="#M000029">new</a>
|
||
|
<a href="#M000032">pretty_print</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<!-- if includes -->
|
||
|
|
||
|
<div id="section">
|
||
|
|
||
|
|
||
|
|
||
|
<div id="aliases-list">
|
||
|
<h3 class="section-bar">External Aliases</h3>
|
||
|
|
||
|
<div class="name-list">
|
||
|
<table summary="aliases">
|
||
|
<tr class="top-aligned-row context-row">
|
||
|
<td class="context-item-name">inspect</td>
|
||
|
<td>-></td>
|
||
|
<td class="context-item-value">old_inspect</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div id="attribute-list">
|
||
|
<h3 class="section-bar">Attributes</h3>
|
||
|
|
||
|
<div class="name-list">
|
||
|
<table>
|
||
|
<tr class="top-aligned-row context-row">
|
||
|
<td class="context-item-name">app</td>
|
||
|
<td class="context-item-value"> [R] </td>
|
||
|
<td class="context-item-desc"></td>
|
||
|
</tr>
|
||
|
<tr class="top-aligned-row context-row">
|
||
|
<td class="context-item-name">for</td>
|
||
|
<td class="context-item-value"> [R] </td>
|
||
|
<td class="context-item-desc"></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<!-- if method_list -->
|
||
|
<div id="methods">
|
||
|
<h3 class="section-bar">Public Class methods</h3>
|
||
|
|
||
|
<div id="method-M000029" class="method-detail">
|
||
|
<a name="M000029"></a>
|
||
|
|
||
|
<div class="method-heading">
|
||
|
<a href="#M000029" class="method-signature">
|
||
|
<span class="method-name">new</span><span class="method-args">(app_f, app_r)</span>
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
|
<div class="method-description">
|
||
|
<p><a class="source-toggle" href="#"
|
||
|
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
||
|
<div class="method-source-code" id="M000029-source">
|
||
|
<pre>
|
||
|
<span class="ruby-comment cmt"># File lib/rack/utils.rb, line 130</span>
|
||
|
130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">app_f</span>, <span class="ruby-identifier">app_r</span>
|
||
|
131: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'running context not provided'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">app_f</span>
|
||
|
132: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'running context does not respond to #context'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">app_f</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:context</span>
|
||
|
133: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'application context not provided'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">app_r</span>
|
||
|
134: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'application context does not respond to #call'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">app_r</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:call</span>
|
||
|
135: <span class="ruby-ivar">@for</span> = <span class="ruby-identifier">app_f</span>
|
||
|
136: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app_r</span>
|
||
|
137: <span class="ruby-keyword kw">end</span>
|
||
|
</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<h3 class="section-bar">Public Instance methods</h3>
|
||
|
|
||
|
<div id="method-M000031" class="method-detail">
|
||
|
<a name="M000031"></a>
|
||
|
|
||
|
<div class="method-heading">
|
||
|
<a href="#M000031" class="method-signature">
|
||
|
<span class="method-name">context</span><span class="method-args">(app_r)</span>
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
|
<div class="method-description">
|
||
|
<p><a class="source-toggle" href="#"
|
||
|
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
||
|
<div class="method-source-code" id="M000031-source">
|
||
|
<pre>
|
||
|
<span class="ruby-comment cmt"># File lib/rack/utils.rb, line 141</span>
|
||
|
141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">context</span> <span class="ruby-identifier">app_r</span>
|
||
|
142: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'new application context not provided'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">app_r</span>
|
||
|
143: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'new application context does not respond to #call'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">app_r</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:call</span>
|
||
|
144: <span class="ruby-ivar">@for</span>.<span class="ruby-identifier">context</span> <span class="ruby-identifier">app_r</span>
|
||
|
145: <span class="ruby-keyword kw">end</span>
|
||
|
</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="method-M000030" class="method-detail">
|
||
|
<a name="M000030"></a>
|
||
|
|
||
|
<div class="method-heading">
|
||
|
<a href="#M000030" class="method-signature">
|
||
|
<span class="method-name">inspect</span><span class="method-args">()</span>
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
|
<div class="method-description">
|
||
|
<p><a class="source-toggle" href="#"
|
||
|
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
||
|
<div class="method-source-code" id="M000030-source">
|
||
|
<pre>
|
||
|
<span class="ruby-comment cmt"># File lib/rack/utils.rb, line 138</span>
|
||
|
138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
|
||
|
139: <span class="ruby-node">"#{old_inspect} ==> #{@for.inspect} ==> #{@app.inspect}"</span>
|
||
|
140: <span class="ruby-keyword kw">end</span>
|
||
|
</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="method-M000032" class="method-detail">
|
||
|
<a name="M000032"></a>
|
||
|
|
||
|
<div class="method-heading">
|
||
|
<a href="#M000032" class="method-signature">
|
||
|
<span class="method-name">pretty_print</span><span class="method-args">(pp)</span>
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
|
<div class="method-description">
|
||
|
<p><a class="source-toggle" href="#"
|
||
|
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
||
|
<div class="method-source-code" id="M000032-source">
|
||
|
<pre>
|
||
|
<span class="ruby-comment cmt"># File lib/rack/utils.rb, line 146</span>
|
||
|
146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pretty_print</span> <span class="ruby-identifier">pp</span>
|
||
|
147: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">text</span> <span class="ruby-identifier">old_inspect</span>
|
||
|
148: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">nest</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">do</span>
|
||
|
149: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">breakable</span>
|
||
|
150: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">text</span> <span class="ruby-value str">'=for> '</span>
|
||
|
151: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">pp</span> <span class="ruby-ivar">@for</span>
|
||
|
152: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">breakable</span>
|
||
|
153: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">text</span> <span class="ruby-value str">'=app> '</span>
|
||
|
154: <span class="ruby-identifier">pp</span>.<span class="ruby-identifier">pp</span> <span class="ruby-ivar">@app</span>
|
||
|
155: <span class="ruby-keyword kw">end</span>
|
||
|
156: <span class="ruby-keyword kw">end</span>
|
||
|
</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div id="validator-badges">
|
||
|
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|