1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00
draper/doc/Draper/AllHelpers.html
2011-09-01 01:17:12 -04:00

256 lines
No EOL
9.7 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>
Module: Draper::AllHelpers
&mdash; Documentation by YARD 0.7.2
</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">
relpath = '..';
if (relpath != '') 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>
<script type="text/javascript" charset="utf-8">
if (window.top.frames.main) document.body.className = 'frames';
</script>
<div id="header">
<div id="menu">
<a href="../_index.html">Index (A)</a> &raquo;
<span class='title'><span class='object_link'><a href="../Draper.html" title="Draper (module)">Draper</a></span></span>
&raquo;
<span class="title">AllHelpers</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 id="class_list_link" href="#">Class List</a>
<a id="method_list_link" href="#">Method List</a>
<a id="file_list_link" href="#">File List</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><h1>Module: Draper::AllHelpers
</h1>
<dl class="box">
<dt class="r1 last">Defined in:</dt>
<dd class="r1 last">lib/draper/all_helpers.rb</dd>
</dl>
<div class="clear"></div>
<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="#all_helpers-instance_method" title="#all_helpers (instance method)">- (Object) <strong>all_helpers</strong> </a>
</span>
<span class="summary_desc"><div class='inline'><p>Most of the black magic here thanks to Xavier Shay (@xshay)
Provide access to helper methods from outside controllers and views,
such as in Presenter objects.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<p class="signature first" id="all_helpers-instance_method">
- (<tt>Object</tt>) <strong>all_helpers</strong>
</p><div class="docstring">
<div class="discussion">
<p>Most of the black magic here thanks to Xavier Shay (@xshay)
Provide access to helper methods from outside controllers and views,
such as in Presenter objects. Rails provides ActionController::Base.helpers,
but this does not include any of our application helpers.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/draper/all_helpers.rb', line 7</span>
<span class='def def kw'>def</span> <span class='all_helpers identifier id'>all_helpers</span>
<span class='@all_helpers_proxy ivar id'>@all_helpers_proxy</span> <span class='opasgn op'>||=</span> <span class='begin begin kw'>begin</span>
<span class='comment val'># Start with just the rails helpers. This is the same method used</span>
<span class='comment val'># by ActionController::Base.helpers</span>
<span class='comment val'># proxy = ActionView::Base.new.extend(_helpers)</span>
<span class='proxy identifier id'>proxy</span> <span class='assign token'>=</span> <span class='ActionController constant id'>ActionController</span><span class='colon2 op'>::</span><span class='Base constant id'>Base</span><span class='dot token'>.</span><span class='helpers identifier id'>helpers</span>
<span class='comment val'># url_for depends on _routes method being defined</span>
<span class='proxy identifier id'>proxy</span><span class='dot token'>.</span><span class='instance_eval identifier id'>instance_eval</span> <span class='do do kw'>do</span>
<span class='def def kw'>def</span> <span class='_routes identifier id'>_routes</span>
<span class='Rails constant id'>Rails</span><span class='dot token'>.</span><span class='application identifier id'>application</span><span class='dot token'>.</span><span class='routes identifier id'>routes</span>
<span class='end end kw'>end</span>
<span class='end end kw'>end</span>
<span class='comment val'># Import all named path methods</span>
<span class='proxy identifier id'>proxy</span><span class='dot token'>.</span><span class='extend identifier id'>extend</span><span class='lparen token'>(</span><span class='Rails constant id'>Rails</span><span class='dot token'>.</span><span class='application identifier id'>application</span><span class='dot token'>.</span><span class='routes identifier id'>routes</span><span class='dot token'>.</span><span class='named_routes identifier id'>named_routes</span><span class='dot token'>.</span><span class='module identifier id'>module</span><span class='rparen token'>)</span>
<span class='comment val'># Load all our application helpers to extend</span>
<span class='modules_for_helpers identifier id'>modules_for_helpers</span><span class='lparen token'>(</span><span class='lbrack token'>[</span><span class='symbol val'>:all</span><span class='rbrack token'>]</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='mod identifier id'>mod</span><span class='bitor op'>|</span>
<span class='proxy identifier id'>proxy</span><span class='dot token'>.</span><span class='extend identifier id'>extend</span><span class='lparen token'>(</span><span class='mod identifier id'>mod</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
<span class='proxy identifier id'>proxy</span><span class='dot token'>.</span><span class='instance_eval identifier id'>instance_eval</span> <span class='do do kw'>do</span>
<span class='def def kw'>def</span> <span class='controller identifier id'>controller</span>
<span class='comment val'>#Object.controller</span>
<span class='end end kw'>end</span>
<span class='end end kw'>end</span>
<span class='proxy identifier id'>proxy</span><span class='dot token'>.</span><span class='instance_eval identifier id'>instance_eval</span> <span class='do do kw'>do</span>
<span class='comment val'># A hack since this proxy doesn't pick up default_url_options from anywhere</span>
<span class='def def kw'>def</span> <span class='url_for identifier id'>url_for</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
<span class='if if kw'>if</span> <span class='args identifier id'>args</span><span class='dot token'>.</span><span class='last identifier id'>last</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='Hash constant id'>Hash</span><span class='rparen token'>)</span> <span class='andop op'>&amp;&amp;</span> <span class='notop op'>!</span><span class='args identifier id'>args</span><span class='dot token'>.</span><span class='last identifier id'>last</span><span class='lbrack token'>[</span><span class='symbol val'>:only_path</span><span class='rbrack token'>]</span>
<span class='args identifier id'>args</span> <span class='assign token'>=</span> <span class='args identifier id'>args</span><span class='dot token'>.</span><span class='dup identifier id'>dup</span>
<span class='args identifier id'>args</span> <span class='lshft op'>&lt;&lt;</span> <span class='args identifier id'>args</span><span class='dot token'>.</span><span class='pop identifier id'>pop</span><span class='dot token'>.</span><span class='merge identifier id'>merge</span><span class='lparen token'>(</span><span class='string val'>'host'</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='ActionMailer constant id'>ActionMailer</span><span class='colon2 op'>::</span><span class='Base constant id'>Base</span><span class='dot token'>.</span><span class='default_url_options identifier id'>default_url_options</span><span class='lbrack token'>[</span><span class='symbol val'>:host</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
<span class='super super kw'>super</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
<span class='end end kw'>end</span>
<span class='proxy identifier id'>proxy</span>
<span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Thu Sep 1 01:13:37 2011 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.7.2 (ruby-1.8.7).
</div>
</body>
</html>