view_models 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +19 -0
- data/.yardoc/checksums +13 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Appraisals +15 -0
- data/CHANGELOG +31 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +174 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +199 -0
- data/Rakefile +24 -0
- data/doc/ModulesInRenderHierarchy.html +186 -0
- data/doc/ModulesInRenderHierarchy/ClassMethods.html +188 -0
- data/doc/ViewModels.html +202 -0
- data/doc/ViewModels/Base.html +1342 -0
- data/doc/ViewModels/ContextExtractor.html +406 -0
- data/doc/ViewModels/Extensions.html +128 -0
- data/doc/ViewModels/Extensions/ModelReader.html +255 -0
- data/doc/ViewModels/Extensions/ModelReader/FilteredDelegationInstaller.html +908 -0
- data/doc/ViewModels/Extensions/ModelReader/Options.html +551 -0
- data/doc/ViewModels/Extensions/View.html +303 -0
- data/doc/ViewModels/Helpers.html +129 -0
- data/doc/ViewModels/Helpers/Mapping.html +562 -0
- data/doc/ViewModels/Helpers/Mapping/Collection.html +844 -0
- data/doc/ViewModels/Helpers/View.html +287 -0
- data/doc/ViewModels/PathStore.html +745 -0
- data/doc/ViewModels/RenderOptions.html +126 -0
- data/doc/ViewModels/RenderOptions/Base.html +1187 -0
- data/doc/ViewModels/RenderOptions/Partial.html +231 -0
- data/doc/ViewModels/RenderOptions/Template.html +231 -0
- data/doc/ViewModels/View.html +414 -0
- data/doc/ViewModelsGenerator.html +410 -0
- data/doc/_index.html +317 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +113 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +113 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +628 -0
- data/doc/top-level-namespace.html +114 -0
- data/feature_support/testapp/app/controllers/heroes_controller.rb +6 -0
- data/feature_support/testapp/app/controllers/users_controller.rb +6 -0
- data/feature_support/testapp/app/helpers/application_helper.rb +8 -0
- data/feature_support/testapp/app/models/hero.rb +8 -0
- data/feature_support/testapp/app/models/user.rb +3 -0
- data/feature_support/testapp/app/view_models/hero.rb +8 -0
- data/feature_support/testapp/app/view_models/test.rb +8 -0
- data/feature_support/testapp/app/view_models/user.rb +14 -0
- data/feature_support/testapp/app/views/heroes/show.html.slim +6 -0
- data/feature_support/testapp/app/views/users/_box.html.slim +8 -0
- data/feature_support/testapp/app/views/users/show.html.slim +6 -0
- data/feature_support/testapp/config/application.rb +64 -0
- data/feature_support/testapp/config/cucumber.yml +8 -0
- data/feature_support/testapp/config/database.yml +28 -0
- data/feature_support/testapp/config/environments/cucumber.rb +11 -0
- data/feature_support/testapp/config/environments/test.rb +27 -0
- data/feature_support/testapp/config/routes.rb +4 -0
- data/feature_support/testapp/db/migrate/1_create_users.rb +13 -0
- data/feature_support/testapp/features/inheritance.feature +16 -0
- data/feature_support/testapp/features/step_definitions/testapp_steps.rb +16 -0
- data/feature_support/testapp/features/support/env.rb +13 -0
- data/feature_support/testapp/features/users.feature +15 -0
- data/feature_support/testapp/lib/tasks/cucumber.rake +31 -0
- data/feature_support/testapp/spec/factories/heroes.rb +7 -0
- data/feature_support/testapp/spec/factories/users.rb +7 -0
- data/features/rails_integration.feature +21 -0
- data/features/step_definitions/rails_steps.rb +112 -0
- data/features/support/env.rb +6 -0
- data/gemfiles/3.0.Gemfile +13 -0
- data/gemfiles/3.1.Gemfile +15 -0
- data/gemfiles/3.2.gemfile +15 -0
- data/lib/rails/generators/view_models/USAGE +6 -0
- data/lib/rails/generators/view_models/templates/views/_collection.html.erb +6 -0
- data/lib/{rails2/generators/view_models/templates/views/view_models/collection → rails/generators/view_models/templates/views}/_collection.html.haml +1 -2
- data/lib/rails/generators/view_models/templates/views/_collection.html.slim +6 -0
- data/lib/{rails2/generators/view_models/templates/views/_empty.html.haml → rails/generators/view_models/templates/views/_empty.html.erb} +0 -0
- data/lib/rails/generators/view_models/templates/views/_empty.html.haml +0 -0
- data/lib/rails/generators/view_models/templates/views/_empty.html.slim +0 -0
- data/lib/rails/generators/view_models/templates/views/_list.html.erb +6 -0
- data/lib/rails/generators/view_models/templates/views/_list.html.haml +4 -0
- data/lib/rails/generators/view_models/templates/views/_list.html.slim +5 -0
- data/lib/rails/generators/view_models/templates/views/_pagination.html.erb +18 -0
- data/lib/{rails2/generators/view_models/templates/views/view_models/collection → rails/generators/view_models/templates/views}/_pagination.html.haml +2 -2
- data/lib/rails/generators/view_models/templates/views/_pagination.html.slim +12 -0
- data/lib/rails/generators/view_models/templates/views/_table.html.erb +10 -0
- data/lib/{rails2/generators/view_models/templates/views/view_models/collection → rails/generators/view_models/templates/views}/_table.html.haml +0 -0
- data/lib/rails/generators/view_models/templates/views/_table.html.slim +5 -0
- data/lib/rails/generators/view_models/view_models_generator.rb +57 -0
- data/lib/view_models.rb +15 -5
- data/lib/{shared/lib/view_models → view_models}/base.rb +148 -37
- data/lib/{shared/lib/view_models → view_models}/context_extractor.rb +6 -2
- data/lib/{shared/lib/view_models → view_models}/extensions/model_reader.rb +27 -13
- data/lib/{rails2/lib → view_models}/extensions/view.rb +6 -1
- data/lib/view_models/helpers/collection.rb +113 -0
- data/lib/{shared/lib/view_models → view_models}/helpers/mapping.rb +12 -15
- data/lib/{rails2/lib → view_models}/helpers/view.rb +5 -1
- data/lib/{shared/lib/view_models → view_models}/path_store.rb +6 -1
- data/lib/{shared/lib/view_models → view_models}/render_options.rb +19 -4
- data/lib/view_models/version.rb +5 -0
- data/lib/{rails2/lib/view_models → view_models}/view.rb +7 -6
- data/spec/{rails2/lib → lib}/view_models/base_spec.rb +38 -5
- data/spec/{rails2/lib → lib/view_models}/extensions/model_reader_spec.rb +4 -4
- data/spec/{shared/lib → lib/view_models}/helpers/collection_spec.rb +21 -1
- data/spec/{shared/lib → lib/view_models}/helpers/mapping_spec.rb +6 -5
- data/spec/{rails2/lib → lib/view_models}/helpers/view_spec.rb +1 -1
- data/spec/lib/view_models/view_spec.rb +42 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/spec_helper_extensions.rb +13 -0
- data/view_models.gemspec +36 -0
- metadata +411 -142
- data/lib/init.rb +0 -1
- data/lib/padrino/README.textile +0 -3
- data/lib/padrino/init.rb +0 -10
- data/lib/padrino/lib/helpers/collection.rb +0 -27
- data/lib/padrino/lib/padrino/view_models.rb +0 -19
- data/lib/padrino/lib/view_models/base.rb +0 -65
- data/lib/rails2/README.textile +0 -3
- data/lib/rails2/TODO.textile +0 -5
- data/lib/rails2/generators/view_models/USAGE +0 -6
- data/lib/rails2/generators/view_models/templates/README +0 -1
- data/lib/rails2/generators/view_models/templates/spec/view_model_spec.rb +0 -7
- data/lib/rails2/generators/view_models/templates/view_models/view_model.rb +0 -5
- data/lib/rails2/generators/view_models/templates/views/view_models/collection/_collection.html.erb +0 -1
- data/lib/rails2/generators/view_models/templates/views/view_models/collection/_collection.text.erb +0 -6
- data/lib/rails2/generators/view_models/templates/views/view_models/collection/_list.html.erb +0 -1
- data/lib/rails2/generators/view_models/templates/views/view_models/collection/_list.text.erb +0 -6
- data/lib/rails2/generators/view_models/templates/views/view_models/collection/_pagination.text.erb +0 -3
- data/lib/rails2/generators/view_models/templates/views/view_models/collection/_table.text.erb +0 -10
- data/lib/rails2/generators/view_models/view_models_generator.rb +0 -47
- data/lib/rails2/init.rb +0 -18
- data/lib/rails2/lib/experimental/README.textile +0 -32
- data/lib/rails2/lib/experimental/modules_in_render_hierarchy.rb +0 -21
- data/lib/rails2/lib/helpers/collection.rb +0 -27
- data/lib/rails2/lib/view_models.rb +0 -1
- data/lib/rails2/lib/view_models/base.rb +0 -99
- data/lib/shared/README.textile +0 -3
- data/lib/shared/init.rb +0 -11
- data/lib/shared/lib/view_models.rb +0 -4
- data/lib/shared/lib/view_models/extensions/active_record.rb +0 -27
- data/lib/shared/lib/view_models/helpers/collection.rb +0 -110
- data/spec/padrino/integration/integration_spec.rb +0 -287
- data/spec/padrino/lib/helpers/collection_spec.rb +0 -30
- data/spec/rails2/integration/integration_spec.rb +0 -279
- data/spec/rails2/lib/extensions/active_record_spec.rb +0 -31
- data/spec/rails2/lib/helpers/collection_spec.rb +0 -30
- data/spec/rails2/lib/view_models/view_spec.rb +0 -12
@@ -0,0 +1,1342 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: ViewModels::Base
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.3
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (B)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../ViewModels.html" title="ViewModels (module)">ViewModels</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Base</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: ViewModels::Base
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">ViewModels::Base</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
<dt class="r2">Extended by:</dt>
|
92
|
+
<dd class="r2"><span class='object_link'><a href="Extensions/ModelReader.html" title="ViewModels::Extensions::ModelReader (module)">Extensions::ModelReader</a></span></dd>
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dt class="r1">Includes:</dt>
|
98
|
+
<dd class="r1">AbstractController::Helpers</dd>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
<dt class="r2 last">Defined in:</dt>
|
105
|
+
<dd class="r2 last">lib/view_models/base.rb</dd>
|
106
|
+
|
107
|
+
</dl>
|
108
|
+
<div class="clear"></div>
|
109
|
+
|
110
|
+
<h2>Overview</h2><div class="docstring">
|
111
|
+
<div class="discussion">
|
112
|
+
|
113
|
+
<p>Base class from which all view_models inherit.</p>
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
<div class="tags">
|
119
|
+
|
120
|
+
<div class="examples">
|
121
|
+
<p class="tag_title">Examples:</p>
|
122
|
+
|
123
|
+
|
124
|
+
<p class="example_title"><div class='inline'>
|
125
|
+
<p>Create Your first View Model</p>
|
126
|
+
</div></p>
|
127
|
+
|
128
|
+
<pre class="example code"><span class='kw'>class</span> <span class='const'>ViewModels</span><span class='op'>::</span><span class='const'>MyViewModel</span> <span class='op'><</span> <span class='const'>ViewModels</span><span class='op'>::</span><span class='const'>Base</span>
|
129
|
+
<span class='comment'># your code
|
130
|
+
</span><span class='kw'>end</span></pre>
|
131
|
+
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<p class="tag_title">Since:</p>
|
135
|
+
<ul class="since">
|
136
|
+
|
137
|
+
<li>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<div class='inline'>
|
144
|
+
<p>1.0.0</p>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
</li>
|
148
|
+
|
149
|
+
</ul>
|
150
|
+
|
151
|
+
</div>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<h2>Class Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
156
|
+
<ul class="summary">
|
157
|
+
|
158
|
+
<li class="public ">
|
159
|
+
<span class="summary_signature">
|
160
|
+
|
161
|
+
<a href="#path_store-class_method" title="path_store (class method)">+ (Object) <strong>path_store</strong> </a>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
</span>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
<span class="summary_desc"><div class='inline'>
|
179
|
+
<p>The path store accessor, storing the view paths for the view model.</p>
|
180
|
+
</div></span>
|
181
|
+
|
182
|
+
</li>
|
183
|
+
|
184
|
+
|
185
|
+
</ul>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
<h2>
|
192
|
+
Class Method Summary
|
193
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
194
|
+
</h2>
|
195
|
+
|
196
|
+
<ul class="summary">
|
197
|
+
|
198
|
+
<li class="public ">
|
199
|
+
<span class="summary_signature">
|
200
|
+
|
201
|
+
<a href="#context_method-class_method" title="context_method (class method)">+ (Object) <strong>context_method</strong>(*methods) </a>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
(also: controller_method)
|
206
|
+
|
207
|
+
</span>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<span class="summary_desc"><div class='inline'>
|
218
|
+
<p>Delegates method calls to the context.</p>
|
219
|
+
</div></span>
|
220
|
+
|
221
|
+
</li>
|
222
|
+
|
223
|
+
|
224
|
+
<li class="public ">
|
225
|
+
<span class="summary_signature">
|
226
|
+
|
227
|
+
<a href="#inherited-class_method" title="inherited (class method)">+ (Object) <strong>inherited</strong>(subclass) </a>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</span>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<span class="summary_desc"><div class='inline'>
|
242
|
+
<p>Installs a path store, a specific store for template inheritance, to
|
243
|
+
remember specific</p>
|
244
|
+
<dl class="rdoc-list label-list"><dt>path, name, format
|
245
|
+
<dd>
|
246
|
+
<p>tuples, pointing to a template path</p>
|
247
|
+
</dd></dl>
|
248
|
+
|
249
|
+
<p>so the view models don't have to always traverse the inheritance chain.</p>
|
250
|
+
</div></span>
|
251
|
+
|
252
|
+
</li>
|
253
|
+
|
254
|
+
|
255
|
+
<li class="public ">
|
256
|
+
<span class="summary_signature">
|
257
|
+
|
258
|
+
<a href="#render-class_method" title="render (class method)">+ (Object) <strong>render</strong>(renderer, options) </a>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
</span>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
<span class="summary_desc"><div class='inline'>
|
273
|
+
<p>Sets the view format and tries to render the given options.</p>
|
274
|
+
</div></span>
|
275
|
+
|
276
|
+
</li>
|
277
|
+
|
278
|
+
|
279
|
+
</ul>
|
280
|
+
|
281
|
+
<h2>
|
282
|
+
Instance Method Summary
|
283
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
284
|
+
</h2>
|
285
|
+
|
286
|
+
<ul class="summary">
|
287
|
+
|
288
|
+
<li class="public ">
|
289
|
+
<span class="summary_signature">
|
290
|
+
|
291
|
+
<a href="#add_template_helper-instance_method" title="#add_template_helper (instance method)">- (Object) <strong>add_template_helper</strong>(helper_module) </a>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
</span>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
<span class="summary_desc"><div class='inline'>
|
306
|
+
<p>Wrapper for add_template_helper in ActionController::Helpers, also includes
|
307
|
+
given helper in the view_model.</p>
|
308
|
+
</div></span>
|
309
|
+
|
310
|
+
</li>
|
311
|
+
|
312
|
+
|
313
|
+
<li class="public ">
|
314
|
+
<span class="summary_signature">
|
315
|
+
|
316
|
+
<a href="#dom_id-instance_method" title="#dom_id (instance method)">- (Object) <strong>dom_id</strong>(*args) </a>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
</span>
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
<span class="summary_desc"><div class='inline'>
|
331
|
+
<p>Delegate dom id to the action controller record identifier.</p>
|
332
|
+
</div></span>
|
333
|
+
|
334
|
+
</li>
|
335
|
+
|
336
|
+
|
337
|
+
<li class="public ">
|
338
|
+
<span class="summary_signature">
|
339
|
+
|
340
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Base) <strong>initialize</strong>(model, app_or_controller_or_view) </a>
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
</span>
|
345
|
+
|
346
|
+
|
347
|
+
<span class="note title constructor">constructor</span>
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
<span class="summary_desc"><div class='inline'>
|
357
|
+
<p>Create a view_model.</p>
|
358
|
+
</div></span>
|
359
|
+
|
360
|
+
</li>
|
361
|
+
|
362
|
+
|
363
|
+
<li class="public ">
|
364
|
+
<span class="summary_signature">
|
365
|
+
|
366
|
+
<a href="#old_add_template_helper-instance_method" title="#old_add_template_helper (instance method)">- (Object) <strong>old_add_template_helper</strong> </a>
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
</span>
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
381
|
+
|
382
|
+
</li>
|
383
|
+
|
384
|
+
|
385
|
+
<li class="public ">
|
386
|
+
<span class="summary_signature">
|
387
|
+
|
388
|
+
<a href="#render_as-instance_method" title="#render_as (instance method)">- (Object) <strong>render_as</strong>(name, options = {}) </a>
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
(also: #render_the)
|
393
|
+
|
394
|
+
</span>
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
<span class="summary_desc"><div class='inline'>
|
405
|
+
<p>Renders the given partial in the view_model's view root in the format
|
406
|
+
given.</p>
|
407
|
+
</div></span>
|
408
|
+
|
409
|
+
</li>
|
410
|
+
|
411
|
+
|
412
|
+
<li class="public ">
|
413
|
+
<span class="summary_signature">
|
414
|
+
|
415
|
+
<a href="#render_template-instance_method" title="#render_template (instance method)">- (Object) <strong>render_template</strong>(name, options = {}) </a>
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
</span>
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
<span class="summary_desc"><div class='inline'>
|
430
|
+
<p>Renders the given template in the view_model's view root in the format
|
431
|
+
given.</p>
|
432
|
+
</div></span>
|
433
|
+
|
434
|
+
</li>
|
435
|
+
|
436
|
+
|
437
|
+
</ul>
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="Extensions/ModelReader.html" title="ViewModels::Extensions::ModelReader (module)">Extensions::ModelReader</a></span></h3>
|
450
|
+
<p class="inherited"><span class='object_link'><a href="Extensions/ModelReader.html#model_reader-instance_method" title="ViewModels::Extensions::ModelReader#model_reader (method)">model_reader</a></span></p>
|
451
|
+
|
452
|
+
<div id="constructor_details" class="method_details_list">
|
453
|
+
<h2>Constructor Details</h2>
|
454
|
+
|
455
|
+
<div class="method_details first">
|
456
|
+
<h3 class="signature first" id="initialize-instance_method">
|
457
|
+
|
458
|
+
- (<tt><span class='object_link'><a href="" title="ViewModels::Base (class)">Base</a></span></tt>) <strong>initialize</strong>(model, app_or_controller_or_view)
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
</h3><div class="docstring">
|
465
|
+
<div class="discussion">
|
466
|
+
|
467
|
+
<p>Create a view_model. To create a view_model, you need to have a model (to
|
468
|
+
present) and a context. The context is usually a view, a controller, or an
|
469
|
+
app, but doesn't need to be.</p>
|
470
|
+
|
471
|
+
<p>The @context = @controller is really only needed because some Rails helpers
|
472
|
+
access @controller directly. It's really bad.</p>
|
473
|
+
|
474
|
+
|
475
|
+
</div>
|
476
|
+
</div>
|
477
|
+
<div class="tags">
|
478
|
+
|
479
|
+
<div class="examples">
|
480
|
+
<p class="tag_title">Examples:</p>
|
481
|
+
|
482
|
+
|
483
|
+
<p class="example_title"><div class='inline'>
|
484
|
+
<p>Initialize a view model without the mapping helper</p>
|
485
|
+
</div></p>
|
486
|
+
|
487
|
+
<pre class="example code"><span class='const'>ViewModel</span><span class='op'>::</span><span class='const'>YourModel</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@model</span><span class='comma'>,</span> <span class='ivar'>@context</span><span class='rparen'>)</span></pre>
|
488
|
+
|
489
|
+
</div>
|
490
|
+
<p class="tag_title">Parameters:</p>
|
491
|
+
<ul class="param">
|
492
|
+
|
493
|
+
<li>
|
494
|
+
|
495
|
+
<span class='name'>model</span>
|
496
|
+
|
497
|
+
|
498
|
+
<span class='type'>(<tt>ActiveRecord</tt>)</span>
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
—
|
503
|
+
<div class='inline'>
|
504
|
+
<p>The model which the view model is based upon</p>
|
505
|
+
</div>
|
506
|
+
|
507
|
+
</li>
|
508
|
+
|
509
|
+
<li>
|
510
|
+
|
511
|
+
<span class='name'>app_or_controller_or_view</span>
|
512
|
+
|
513
|
+
|
514
|
+
<span class='type'>(<tt>ActionView</tt>, <tt>ActionController</tt>, <tt>Rails::Application</tt>)</span>
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
—
|
519
|
+
<div class='inline'>
|
520
|
+
<p>The context of the view model</p>
|
521
|
+
</div>
|
522
|
+
|
523
|
+
</li>
|
524
|
+
|
525
|
+
</ul>
|
526
|
+
|
527
|
+
<p class="tag_title">Since:</p>
|
528
|
+
<ul class="since">
|
529
|
+
|
530
|
+
<li>
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
<div class='inline'>
|
537
|
+
<p>1.0.0</p>
|
538
|
+
</div>
|
539
|
+
|
540
|
+
</li>
|
541
|
+
|
542
|
+
</ul>
|
543
|
+
|
544
|
+
</div><table class="source_code">
|
545
|
+
<tr>
|
546
|
+
<td>
|
547
|
+
<pre class="lines">
|
548
|
+
|
549
|
+
|
550
|
+
38
|
551
|
+
39
|
552
|
+
40
|
553
|
+
41</pre>
|
554
|
+
</td>
|
555
|
+
<td>
|
556
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 38</span>
|
557
|
+
|
558
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_model'>model</span><span class='comma'>,</span> <span class='id identifier rubyid_app_or_controller_or_view'>app_or_controller_or_view</span>
|
559
|
+
<span class='ivar'>@model</span> <span class='op'>=</span> <span class='id identifier rubyid_model'>model</span>
|
560
|
+
<span class='ivar'>@context</span> <span class='op'>=</span> <span class='ivar'>@controller</span> <span class='op'>=</span> <span class='const'>ContextExtractor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_app_or_controller_or_view'>app_or_controller_or_view</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_extract'>extract</span>
|
561
|
+
<span class='kw'>end</span></pre>
|
562
|
+
</td>
|
563
|
+
</tr>
|
564
|
+
</table>
|
565
|
+
</div>
|
566
|
+
|
567
|
+
</div>
|
568
|
+
|
569
|
+
<div id="class_attr_details" class="attr_details">
|
570
|
+
<h2>Class Attribute Details</h2>
|
571
|
+
|
572
|
+
|
573
|
+
<span id="path_store=-class_method"></span>
|
574
|
+
<div class="method_details first">
|
575
|
+
<h3 class="signature first" id="path_store-class_method">
|
576
|
+
|
577
|
+
+ (<tt>Object</tt>) <strong>path_store</strong>
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
</h3><div class="docstring">
|
584
|
+
<div class="discussion">
|
585
|
+
|
586
|
+
<p>The path store accessor, storing the view paths for the view model</p>
|
587
|
+
|
588
|
+
|
589
|
+
</div>
|
590
|
+
</div>
|
591
|
+
<div class="tags">
|
592
|
+
|
593
|
+
<p class="tag_title">Since:</p>
|
594
|
+
<ul class="since">
|
595
|
+
|
596
|
+
<li>
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
<div class='inline'>
|
603
|
+
<p>1.0.0</p>
|
604
|
+
</div>
|
605
|
+
|
606
|
+
</li>
|
607
|
+
|
608
|
+
</ul>
|
609
|
+
|
610
|
+
</div><table class="source_code">
|
611
|
+
<tr>
|
612
|
+
<td>
|
613
|
+
<pre class="lines">
|
614
|
+
|
615
|
+
|
616
|
+
47
|
617
|
+
48
|
618
|
+
49</pre>
|
619
|
+
</td>
|
620
|
+
<td>
|
621
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 47</span>
|
622
|
+
|
623
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_path_store'>path_store</span>
|
624
|
+
<span class='ivar'>@path_store</span>
|
625
|
+
<span class='kw'>end</span></pre>
|
626
|
+
</td>
|
627
|
+
</tr>
|
628
|
+
</table>
|
629
|
+
</div>
|
630
|
+
|
631
|
+
</div>
|
632
|
+
|
633
|
+
|
634
|
+
<div id="class_method_details" class="method_details_list">
|
635
|
+
<h2>Class Method Details</h2>
|
636
|
+
|
637
|
+
|
638
|
+
<div class="method_details first">
|
639
|
+
<h3 class="signature first" id="context_method-class_method">
|
640
|
+
|
641
|
+
+ (<tt>Object</tt>) <strong>context_method</strong>(*methods)
|
642
|
+
|
643
|
+
|
644
|
+
|
645
|
+
<span class="aliases">Also known as:
|
646
|
+
<span class="names"><span id='controller_method-class_method'>controller_method</span></span>
|
647
|
+
</span>
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
</h3><div class="docstring">
|
652
|
+
<div class="discussion">
|
653
|
+
|
654
|
+
<p>Delegates method calls to the context. In the view_model:</p>
|
655
|
+
|
656
|
+
<pre class="code ruby"><code><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_user'>current_user</span></code></pre>
|
657
|
+
|
658
|
+
<p>will call</p>
|
659
|
+
|
660
|
+
<pre class="code ruby"><code><span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_current_user'>current_user</span></code></pre>
|
661
|
+
|
662
|
+
|
663
|
+
</div>
|
664
|
+
</div>
|
665
|
+
<div class="tags">
|
666
|
+
|
667
|
+
<div class="examples">
|
668
|
+
<p class="tag_title">Examples:</p>
|
669
|
+
|
670
|
+
|
671
|
+
<p class="example_title"><div class='inline'>
|
672
|
+
<p>delegate one method to the context</p>
|
673
|
+
</div></p>
|
674
|
+
|
675
|
+
<pre class="example code"><span class='id identifier rubyid_context_method'>context_method</span> <span class='symbol'>:current_user</span></pre>
|
676
|
+
|
677
|
+
|
678
|
+
<p class="example_title"><div class='inline'>
|
679
|
+
<p>delegate multiple methods to the context</p>
|
680
|
+
</div></p>
|
681
|
+
|
682
|
+
<pre class="example code"><span class='id identifier rubyid_context_method'>context_method</span> <span class='symbol'>:current_user</span><span class='comma'>,</span> <span class='symbol'>:current_profile</span></pre>
|
683
|
+
|
684
|
+
</div>
|
685
|
+
<p class="tag_title">Parameters:</p>
|
686
|
+
<ul class="param">
|
687
|
+
|
688
|
+
<li>
|
689
|
+
|
690
|
+
<span class='name'>methods</span>
|
691
|
+
|
692
|
+
|
693
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
—
|
698
|
+
<div class='inline'>
|
699
|
+
<p>A list of symbols representing methods to be delegated</p>
|
700
|
+
</div>
|
701
|
+
|
702
|
+
</li>
|
703
|
+
|
704
|
+
</ul>
|
705
|
+
|
706
|
+
<p class="tag_title">Since:</p>
|
707
|
+
<ul class="since">
|
708
|
+
|
709
|
+
<li>
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
<div class='inline'>
|
716
|
+
<p>1.0.0</p>
|
717
|
+
</div>
|
718
|
+
|
719
|
+
</li>
|
720
|
+
|
721
|
+
</ul>
|
722
|
+
|
723
|
+
</div><table class="source_code">
|
724
|
+
<tr>
|
725
|
+
<td>
|
726
|
+
<pre class="lines">
|
727
|
+
|
728
|
+
|
729
|
+
71
|
730
|
+
72
|
731
|
+
73</pre>
|
732
|
+
</td>
|
733
|
+
<td>
|
734
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 71</span>
|
735
|
+
|
736
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_context_method'>context_method</span> <span class='op'>*</span><span class='id identifier rubyid_methods'>methods</span>
|
737
|
+
<span class='id identifier rubyid_delegate'>delegate</span> <span class='op'>*</span><span class='id identifier rubyid_methods'>methods</span> <span class='op'><<</span> <span class='lbrace'>{</span> <span class='symbol'>:to</span> <span class='op'>=></span> <span class='symbol'>:context</span> <span class='rbrace'>}</span>
|
738
|
+
<span class='kw'>end</span></pre>
|
739
|
+
</td>
|
740
|
+
</tr>
|
741
|
+
</table>
|
742
|
+
</div>
|
743
|
+
|
744
|
+
<div class="method_details ">
|
745
|
+
<h3 class="signature " id="inherited-class_method">
|
746
|
+
|
747
|
+
+ (<tt>Object</tt>) <strong>inherited</strong>(subclass)
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
|
752
|
+
|
753
|
+
</h3><div class="docstring">
|
754
|
+
<div class="discussion">
|
755
|
+
|
756
|
+
<p>Installs a path store, a specific store for template inheritance, to
|
757
|
+
remember specific</p>
|
758
|
+
<dl class="rdoc-list label-list"><dt>path, name, format
|
759
|
+
<dd>
|
760
|
+
<p>tuples, pointing to a template path</p>
|
761
|
+
</dd></dl>
|
762
|
+
|
763
|
+
<p>so the view models don't have to always traverse the inheritance chain.</p>
|
764
|
+
|
765
|
+
|
766
|
+
</div>
|
767
|
+
</div>
|
768
|
+
<div class="tags">
|
769
|
+
<p class="tag_title">Parameters:</p>
|
770
|
+
<ul class="param">
|
771
|
+
|
772
|
+
<li>
|
773
|
+
|
774
|
+
<span class='name'>subclass</span>
|
775
|
+
|
776
|
+
|
777
|
+
<span class='type'>(<tt>ViewModel</tt>)</span>
|
778
|
+
|
779
|
+
|
780
|
+
|
781
|
+
—
|
782
|
+
<div class='inline'>
|
783
|
+
<p>The subclass of the view model</p>
|
784
|
+
</div>
|
785
|
+
|
786
|
+
</li>
|
787
|
+
|
788
|
+
</ul>
|
789
|
+
|
790
|
+
<p class="tag_title">Since:</p>
|
791
|
+
<ul class="since">
|
792
|
+
|
793
|
+
<li>
|
794
|
+
|
795
|
+
|
796
|
+
|
797
|
+
|
798
|
+
|
799
|
+
<div class='inline'>
|
800
|
+
<p>1.0.0</p>
|
801
|
+
</div>
|
802
|
+
|
803
|
+
</li>
|
804
|
+
|
805
|
+
</ul>
|
806
|
+
|
807
|
+
</div><table class="source_code">
|
808
|
+
<tr>
|
809
|
+
<td>
|
810
|
+
<pre class="lines">
|
811
|
+
|
812
|
+
|
813
|
+
54
|
814
|
+
55
|
815
|
+
56
|
816
|
+
57</pre>
|
817
|
+
</td>
|
818
|
+
<td>
|
819
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 54</span>
|
820
|
+
|
821
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_inherited'>inherited</span> <span class='id identifier rubyid_subclass'>subclass</span>
|
822
|
+
<span class='const'>ViewModels</span><span class='op'>::</span><span class='const'>PathStore</span><span class='period'>.</span><span class='id identifier rubyid_install_in'>install_in</span> <span class='id identifier rubyid_subclass'>subclass</span>
|
823
|
+
<span class='kw'>super</span>
|
824
|
+
<span class='kw'>end</span></pre>
|
825
|
+
</td>
|
826
|
+
</tr>
|
827
|
+
</table>
|
828
|
+
</div>
|
829
|
+
|
830
|
+
<div class="method_details ">
|
831
|
+
<h3 class="signature " id="render-class_method">
|
832
|
+
|
833
|
+
+ (<tt>Object</tt>) <strong>render</strong>(renderer, options)
|
834
|
+
|
835
|
+
|
836
|
+
|
837
|
+
|
838
|
+
|
839
|
+
</h3><div class="docstring">
|
840
|
+
<div class="discussion">
|
841
|
+
|
842
|
+
<div class="note notetag">
|
843
|
+
<strong>Note:</strong>
|
844
|
+
<div class='inline'>
|
845
|
+
<p>Also caches [path, name, format] => template path.</p>
|
846
|
+
</div>
|
847
|
+
</div>
|
848
|
+
|
849
|
+
|
850
|
+
<p>Sets the view format and tries to render the given options.</p>
|
851
|
+
|
852
|
+
|
853
|
+
</div>
|
854
|
+
</div>
|
855
|
+
<div class="tags">
|
856
|
+
<p class="tag_title">Parameters:</p>
|
857
|
+
<ul class="param">
|
858
|
+
|
859
|
+
<li>
|
860
|
+
|
861
|
+
<span class='name'>renderer</span>
|
862
|
+
|
863
|
+
|
864
|
+
<span class='type'>(<tt>ActionView</tt>)</span>
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
—
|
869
|
+
<div class='inline'>
|
870
|
+
<p>The view renderer</p>
|
871
|
+
</div>
|
872
|
+
|
873
|
+
</li>
|
874
|
+
|
875
|
+
<li>
|
876
|
+
|
877
|
+
<span class='name'>options</span>
|
878
|
+
|
879
|
+
|
880
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
881
|
+
|
882
|
+
|
883
|
+
|
884
|
+
—
|
885
|
+
<div class='inline'>
|
886
|
+
<p>The options to pass to the view</p>
|
887
|
+
</div>
|
888
|
+
|
889
|
+
</li>
|
890
|
+
|
891
|
+
</ul>
|
892
|
+
|
893
|
+
|
894
|
+
|
895
|
+
|
896
|
+
|
897
|
+
|
898
|
+
<p class="tag_title">Options Hash (<tt>options</tt>):</p>
|
899
|
+
<ul class="option">
|
900
|
+
|
901
|
+
<li>
|
902
|
+
<span class="name">:locals</span>
|
903
|
+
<span class="type">(<tt>Hash</tt>)</span>
|
904
|
+
<span class="default">
|
905
|
+
|
906
|
+
</span>
|
907
|
+
|
908
|
+
— <div class='inline'>
|
909
|
+
<p>The locals to pass to the view</p>
|
910
|
+
</div>
|
911
|
+
|
912
|
+
</li>
|
913
|
+
|
914
|
+
</ul>
|
915
|
+
|
916
|
+
|
917
|
+
<p class="tag_title">Since:</p>
|
918
|
+
<ul class="since">
|
919
|
+
|
920
|
+
<li>
|
921
|
+
|
922
|
+
|
923
|
+
|
924
|
+
|
925
|
+
|
926
|
+
<div class='inline'>
|
927
|
+
<p>1.0.0</p>
|
928
|
+
</div>
|
929
|
+
|
930
|
+
</li>
|
931
|
+
|
932
|
+
</ul>
|
933
|
+
|
934
|
+
</div><table class="source_code">
|
935
|
+
<tr>
|
936
|
+
<td>
|
937
|
+
<pre class="lines">
|
938
|
+
|
939
|
+
|
940
|
+
105
|
941
|
+
106
|
942
|
+
107
|
943
|
+
108
|
944
|
+
109
|
945
|
+
110
|
946
|
+
111</pre>
|
947
|
+
</td>
|
948
|
+
<td>
|
949
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 105</span>
|
950
|
+
|
951
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span> <span class='id identifier rubyid_renderer'>renderer</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
|
952
|
+
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_format!'>format!</span> <span class='id identifier rubyid_renderer'>renderer</span>
|
953
|
+
<span class='id identifier rubyid_path_store'>path_store</span><span class='period'>.</span><span class='id identifier rubyid_cached'>cached</span> <span class='id identifier rubyid_options'>options</span> <span class='kw'>do</span>
|
954
|
+
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='id identifier rubyid_template_path'>template_path</span> <span class='id identifier rubyid_renderer'>renderer</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
|
955
|
+
<span class='id identifier rubyid_renderer'>renderer</span><span class='period'>.</span><span class='id identifier rubyid_render_with'>render_with</span> <span class='id identifier rubyid_options'>options</span>
|
956
|
+
<span class='kw'>end</span>
|
957
|
+
<span class='kw'>end</span></pre>
|
958
|
+
</td>
|
959
|
+
</tr>
|
960
|
+
</table>
|
961
|
+
</div>
|
962
|
+
|
963
|
+
</div>
|
964
|
+
|
965
|
+
<div id="instance_method_details" class="method_details_list">
|
966
|
+
<h2>Instance Method Details</h2>
|
967
|
+
|
968
|
+
|
969
|
+
<div class="method_details first">
|
970
|
+
<h3 class="signature first" id="add_template_helper-instance_method">
|
971
|
+
|
972
|
+
- (<tt>Object</tt>) <strong>add_template_helper</strong>(helper_module)
|
973
|
+
|
974
|
+
|
975
|
+
|
976
|
+
|
977
|
+
|
978
|
+
</h3><div class="docstring">
|
979
|
+
<div class="discussion">
|
980
|
+
|
981
|
+
<div class="note todo">
|
982
|
+
<strong>TODO:</strong>
|
983
|
+
<div class='inline'>
|
984
|
+
<p>extract into module</p>
|
985
|
+
</div>
|
986
|
+
</div>
|
987
|
+
|
988
|
+
|
989
|
+
<p>Wrapper for add_template_helper in ActionController::Helpers, also includes
|
990
|
+
given helper in the view_model</p>
|
991
|
+
|
992
|
+
|
993
|
+
</div>
|
994
|
+
</div>
|
995
|
+
<div class="tags">
|
996
|
+
<p class="tag_title">Parameters:</p>
|
997
|
+
<ul class="param">
|
998
|
+
|
999
|
+
<li>
|
1000
|
+
|
1001
|
+
<span class='name'>helper_module</span>
|
1002
|
+
|
1003
|
+
|
1004
|
+
<span class='type'>(<tt>Module</tt>)</span>
|
1005
|
+
|
1006
|
+
|
1007
|
+
|
1008
|
+
—
|
1009
|
+
<div class='inline'>
|
1010
|
+
<p>the helper to be added</p>
|
1011
|
+
</div>
|
1012
|
+
|
1013
|
+
</li>
|
1014
|
+
|
1015
|
+
</ul>
|
1016
|
+
|
1017
|
+
<p class="tag_title">Since:</p>
|
1018
|
+
<ul class="since">
|
1019
|
+
|
1020
|
+
<li>
|
1021
|
+
|
1022
|
+
|
1023
|
+
|
1024
|
+
|
1025
|
+
|
1026
|
+
<div class='inline'>
|
1027
|
+
<p>1.0.0</p>
|
1028
|
+
</div>
|
1029
|
+
|
1030
|
+
</li>
|
1031
|
+
|
1032
|
+
</ul>
|
1033
|
+
|
1034
|
+
</div><table class="source_code">
|
1035
|
+
<tr>
|
1036
|
+
<td>
|
1037
|
+
<pre class="lines">
|
1038
|
+
|
1039
|
+
|
1040
|
+
93
|
1041
|
+
94
|
1042
|
+
95
|
1043
|
+
96</pre>
|
1044
|
+
</td>
|
1045
|
+
<td>
|
1046
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 93</span>
|
1047
|
+
|
1048
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_add_template_helper'>add_template_helper</span> <span class='id identifier rubyid_helper_module'>helper_module</span>
|
1049
|
+
<span class='id identifier rubyid_include'>include</span> <span class='id identifier rubyid_helper_module'>helper_module</span>
|
1050
|
+
<span class='id identifier rubyid_old_add_template_helper'>old_add_template_helper</span> <span class='id identifier rubyid_helper_module'>helper_module</span>
|
1051
|
+
<span class='kw'>end</span></pre>
|
1052
|
+
</td>
|
1053
|
+
</tr>
|
1054
|
+
</table>
|
1055
|
+
</div>
|
1056
|
+
|
1057
|
+
<div class="method_details ">
|
1058
|
+
<h3 class="signature " id="dom_id-instance_method">
|
1059
|
+
|
1060
|
+
- (<tt>Object</tt>) <strong>dom_id</strong>(*args)
|
1061
|
+
|
1062
|
+
|
1063
|
+
|
1064
|
+
|
1065
|
+
|
1066
|
+
</h3><div class="docstring">
|
1067
|
+
<div class="discussion">
|
1068
|
+
|
1069
|
+
<p>Delegate dom id to the action controller record identifier.</p>
|
1070
|
+
|
1071
|
+
|
1072
|
+
</div>
|
1073
|
+
</div>
|
1074
|
+
<div class="tags">
|
1075
|
+
|
1076
|
+
<p class="tag_title">Since:</p>
|
1077
|
+
<ul class="since">
|
1078
|
+
|
1079
|
+
<li>
|
1080
|
+
|
1081
|
+
|
1082
|
+
|
1083
|
+
|
1084
|
+
|
1085
|
+
<div class='inline'>
|
1086
|
+
<p>1.0.0</p>
|
1087
|
+
</div>
|
1088
|
+
|
1089
|
+
</li>
|
1090
|
+
|
1091
|
+
</ul>
|
1092
|
+
|
1093
|
+
</div><table class="source_code">
|
1094
|
+
<tr>
|
1095
|
+
<td>
|
1096
|
+
<pre class="lines">
|
1097
|
+
|
1098
|
+
|
1099
|
+
226
|
1100
|
+
227
|
1101
|
+
228
|
1102
|
+
229
|
1103
|
+
230
|
1104
|
+
231
|
1105
|
+
232</pre>
|
1106
|
+
</td>
|
1107
|
+
<td>
|
1108
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 226</span>
|
1109
|
+
|
1110
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_dom_id'>dom_id</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
|
1111
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1112
|
+
<span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_dom_id'>dom_id</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
|
1113
|
+
<span class='kw'>else</span>
|
1114
|
+
<span class='const'>ActionController</span><span class='op'>::</span><span class='const'>RecordIdentifier</span><span class='period'>.</span><span class='id identifier rubyid_dom_id'>dom_id</span> <span class='id identifier rubyid_model'>model</span>
|
1115
|
+
<span class='kw'>end</span>
|
1116
|
+
<span class='kw'>end</span></pre>
|
1117
|
+
</td>
|
1118
|
+
</tr>
|
1119
|
+
</table>
|
1120
|
+
</div>
|
1121
|
+
|
1122
|
+
<div class="method_details ">
|
1123
|
+
<h3 class="signature " id="old_add_template_helper-instance_method">
|
1124
|
+
|
1125
|
+
- (<tt>Object</tt>) <strong>old_add_template_helper</strong>
|
1126
|
+
|
1127
|
+
|
1128
|
+
|
1129
|
+
|
1130
|
+
|
1131
|
+
</h3><div class="docstring">
|
1132
|
+
<div class="discussion">
|
1133
|
+
|
1134
|
+
|
1135
|
+
</div>
|
1136
|
+
</div>
|
1137
|
+
<div class="tags">
|
1138
|
+
|
1139
|
+
<p class="tag_title">Since:</p>
|
1140
|
+
<ul class="since">
|
1141
|
+
|
1142
|
+
<li>
|
1143
|
+
|
1144
|
+
|
1145
|
+
|
1146
|
+
|
1147
|
+
|
1148
|
+
<div class='inline'>
|
1149
|
+
<p>1.0.0</p>
|
1150
|
+
</div>
|
1151
|
+
|
1152
|
+
</li>
|
1153
|
+
|
1154
|
+
</ul>
|
1155
|
+
|
1156
|
+
</div><table class="source_code">
|
1157
|
+
<tr>
|
1158
|
+
<td>
|
1159
|
+
<pre class="lines">
|
1160
|
+
|
1161
|
+
|
1162
|
+
85</pre>
|
1163
|
+
</td>
|
1164
|
+
<td>
|
1165
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 85</span>
|
1166
|
+
|
1167
|
+
<span class='kw'>alias</span> <span class='id identifier rubyid_old_add_template_helper'>old_add_template_helper</span> <span class='id identifier rubyid_add_template_helper'>add_template_helper</span></pre>
|
1168
|
+
</td>
|
1169
|
+
</tr>
|
1170
|
+
</table>
|
1171
|
+
</div>
|
1172
|
+
|
1173
|
+
<div class="method_details ">
|
1174
|
+
<h3 class="signature " id="render_as-instance_method">
|
1175
|
+
|
1176
|
+
- (<tt>Object</tt>) <strong>render_as</strong>(name, options = {})
|
1177
|
+
|
1178
|
+
|
1179
|
+
|
1180
|
+
<span class="aliases">Also known as:
|
1181
|
+
<span class="names"><span id='render_the-instance_method'>render_the</span></span>
|
1182
|
+
</span>
|
1183
|
+
|
1184
|
+
|
1185
|
+
|
1186
|
+
</h3><div class="docstring">
|
1187
|
+
<div class="discussion">
|
1188
|
+
|
1189
|
+
<p>Renders the given partial in the view_model's view root in the format
|
1190
|
+
given.</p>
|
1191
|
+
|
1192
|
+
<p>Example:</p>
|
1193
|
+
|
1194
|
+
<pre class="code ruby"><code><span class='id identifier rubyid_views'>views</span><span class='op'>/</span><span class='id identifier rubyid_view_models'>view_models</span><span class='op'>/</span><span class='id identifier rubyid_this'>this</span><span class='op'>/</span><span class='id identifier rubyid_view_model'>view_model</span><span class='op'>/</span><span class='id identifier rubyid__partial'>_partial</span><span class='period'>.</span><span class='id identifier rubyid_haml'>haml</span>
|
1195
|
+
<span class='id identifier rubyid_views'>views</span><span class='op'>/</span><span class='id identifier rubyid_view_models'>view_models</span><span class='op'>/</span><span class='id identifier rubyid_this'>this</span><span class='op'>/</span><span class='id identifier rubyid_view_model'>view_model</span><span class='op'>/</span><span class='id identifier rubyid__partial'>_partial</span><span class='period'>.</span><span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_erb'>erb</span></code></pre>
|
1196
|
+
|
1197
|
+
<p>The following options are supported:</p>
|
1198
|
+
<ul><li>
|
1199
|
+
<p>:format - Calling view_model.render_as('partial') will render the haml
|
1200
|
+
partial, calling view_model.render_as('partial', :format => :text) will
|
1201
|
+
render the text erb.</p>
|
1202
|
+
</li><li>
|
1203
|
+
<p>All other options are passed on to the render call. I.e. if you want to
|
1204
|
+
specify locals you can call view_model.render_as(:partial, :locals => {
|
1205
|
+
:name => :value })</p>
|
1206
|
+
</li><li>
|
1207
|
+
<p>If no format is given, it will render the default format, which is
|
1208
|
+
(currently) html.</p>
|
1209
|
+
</li></ul>
|
1210
|
+
|
1211
|
+
|
1212
|
+
</div>
|
1213
|
+
</div>
|
1214
|
+
<div class="tags">
|
1215
|
+
|
1216
|
+
<p class="tag_title">Since:</p>
|
1217
|
+
<ul class="since">
|
1218
|
+
|
1219
|
+
<li>
|
1220
|
+
|
1221
|
+
|
1222
|
+
|
1223
|
+
|
1224
|
+
|
1225
|
+
<div class='inline'>
|
1226
|
+
<p>1.0.0</p>
|
1227
|
+
</div>
|
1228
|
+
|
1229
|
+
</li>
|
1230
|
+
|
1231
|
+
</ul>
|
1232
|
+
|
1233
|
+
</div><table class="source_code">
|
1234
|
+
<tr>
|
1235
|
+
<td>
|
1236
|
+
<pre class="lines">
|
1237
|
+
|
1238
|
+
|
1239
|
+
258
|
1240
|
+
259
|
1241
|
+
260</pre>
|
1242
|
+
</td>
|
1243
|
+
<td>
|
1244
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 258</span>
|
1245
|
+
|
1246
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_render_as'>render_as</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
1247
|
+
<span class='id identifier rubyid_render_internal'>render_internal</span> <span class='const'>RenderOptions</span><span class='op'>::</span><span class='const'>Partial</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
1248
|
+
<span class='kw'>end</span></pre>
|
1249
|
+
</td>
|
1250
|
+
</tr>
|
1251
|
+
</table>
|
1252
|
+
</div>
|
1253
|
+
|
1254
|
+
<div class="method_details ">
|
1255
|
+
<h3 class="signature " id="render_template-instance_method">
|
1256
|
+
|
1257
|
+
- (<tt>Object</tt>) <strong>render_template</strong>(name, options = {})
|
1258
|
+
|
1259
|
+
|
1260
|
+
|
1261
|
+
|
1262
|
+
|
1263
|
+
</h3><div class="docstring">
|
1264
|
+
<div class="discussion">
|
1265
|
+
|
1266
|
+
<p>Renders the given template in the view_model's view root in the format
|
1267
|
+
given.</p>
|
1268
|
+
|
1269
|
+
<p>Example:</p>
|
1270
|
+
|
1271
|
+
<pre class="code ruby"><code>views/view_models/this/view_model/template.haml
|
1272
|
+
views/view_models/this/view_model/template name.text.erb</code></pre>
|
1273
|
+
|
1274
|
+
<p>The following options are supported:</p>
|
1275
|
+
<ul><li>
|
1276
|
+
<p>:format - Calling view_model.render_template('template') will render the
|
1277
|
+
haml template, calling view_model.render_template('template', :format =>
|
1278
|
+
:text) will render the text erb template.</p>
|
1279
|
+
</li><li>
|
1280
|
+
<p>All other options are passed on to the render call. I.e. if you want to
|
1281
|
+
specify locals you can call view_model.render_template(:template, :locals
|
1282
|
+
=> { :name => :value })</p>
|
1283
|
+
</li><li>
|
1284
|
+
<p>If no format is given, it will render the default format, which is
|
1285
|
+
(currently) html.</p>
|
1286
|
+
</li></ul>
|
1287
|
+
|
1288
|
+
|
1289
|
+
</div>
|
1290
|
+
</div>
|
1291
|
+
<div class="tags">
|
1292
|
+
|
1293
|
+
<p class="tag_title">Since:</p>
|
1294
|
+
<ul class="since">
|
1295
|
+
|
1296
|
+
<li>
|
1297
|
+
|
1298
|
+
|
1299
|
+
|
1300
|
+
|
1301
|
+
|
1302
|
+
<div class='inline'>
|
1303
|
+
<p>1.0.0</p>
|
1304
|
+
</div>
|
1305
|
+
|
1306
|
+
</li>
|
1307
|
+
|
1308
|
+
</ul>
|
1309
|
+
|
1310
|
+
</div><table class="source_code">
|
1311
|
+
<tr>
|
1312
|
+
<td>
|
1313
|
+
<pre class="lines">
|
1314
|
+
|
1315
|
+
|
1316
|
+
284
|
1317
|
+
285
|
1318
|
+
286</pre>
|
1319
|
+
</td>
|
1320
|
+
<td>
|
1321
|
+
<pre class="code"><span class="info file"># File 'lib/view_models/base.rb', line 284</span>
|
1322
|
+
|
1323
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_render_template'>render_template</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
1324
|
+
<span class='id identifier rubyid_render_internal'>render_internal</span> <span class='const'>RenderOptions</span><span class='op'>::</span><span class='const'>Template</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
1325
|
+
<span class='kw'>end</span></pre>
|
1326
|
+
</td>
|
1327
|
+
</tr>
|
1328
|
+
</table>
|
1329
|
+
</div>
|
1330
|
+
|
1331
|
+
</div>
|
1332
|
+
|
1333
|
+
</div>
|
1334
|
+
|
1335
|
+
<div id="footer">
|
1336
|
+
Generated on Tue Oct 16 23:27:35 2012 by
|
1337
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1338
|
+
0.8.3 (ruby-1.9.3).
|
1339
|
+
</div>
|
1340
|
+
|
1341
|
+
</body>
|
1342
|
+
</html>
|