prismic.io 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -14
- data/docs/Prismic.html +1074 -0
- data/docs/Prismic/API.html +2987 -0
- data/docs/Prismic/API/BadPrismicResponseError.html +147 -0
- data/docs/Prismic/API/OAuth.html +560 -0
- data/docs/Prismic/API/PrismicWSAuthError.html +375 -0
- data/docs/Prismic/API/PrismicWSConnectionError.html +221 -0
- data/docs/Prismic/BasicNullCache.html +255 -0
- data/docs/Prismic/DefaultHTTPClient.html +350 -0
- data/docs/Prismic/Document.html +873 -0
- data/docs/Prismic/Error.html +418 -0
- data/docs/Prismic/Experiment.html +633 -0
- data/docs/Prismic/Experiments.html +633 -0
- data/docs/Prismic/Field.html +424 -0
- data/docs/Prismic/Form.html +827 -0
- data/docs/Prismic/Fragments.html +117 -0
- data/docs/Prismic/Fragments/Color.html +632 -0
- data/docs/Prismic/Fragments/Date.html +399 -0
- data/docs/Prismic/Fragments/DocumentLink.html +1048 -0
- data/docs/Prismic/Fragments/Embed.html +679 -0
- data/docs/Prismic/Fragments/FileLink.html +604 -0
- data/docs/Prismic/Fragments/Fragment.html +339 -0
- data/docs/Prismic/Fragments/GeoPoint.html +469 -0
- data/docs/Prismic/Fragments/Group.html +710 -0
- data/docs/Prismic/Fragments/GroupDocument.html +382 -0
- data/docs/Prismic/Fragments/Image.html +780 -0
- data/docs/Prismic/Fragments/Image/View.html +759 -0
- data/docs/Prismic/Fragments/Image/ViewDoesNotExistException.html +147 -0
- data/docs/Prismic/Fragments/ImageLink.html +336 -0
- data/docs/Prismic/Fragments/Link.html +412 -0
- data/docs/Prismic/Fragments/Multiple.html +513 -0
- data/docs/Prismic/Fragments/Number.html +401 -0
- data/docs/Prismic/Fragments/Select.html +349 -0
- data/docs/Prismic/Fragments/Separator.html +396 -0
- data/docs/Prismic/Fragments/Slice.html +632 -0
- data/docs/Prismic/Fragments/SliceZone.html +474 -0
- data/docs/Prismic/Fragments/StructuredText.html +664 -0
- data/docs/Prismic/Fragments/StructuredText/Block.html +232 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Embed.html +367 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Heading.html +366 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Image.html +755 -0
- data/docs/Prismic/Fragments/StructuredText/Block/ListItem.html +372 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Paragraph.html +223 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Preformatted.html +223 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Text.html +818 -0
- data/docs/Prismic/Fragments/StructuredText/BlockGroup.html +423 -0
- data/docs/Prismic/Fragments/StructuredText/Span.html +384 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Em.html +213 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Hyperlink.html +359 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Label.html +362 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Strong.html +213 -0
- data/docs/Prismic/Fragments/Text.html +396 -0
- data/docs/Prismic/Fragments/Timestamp.html +399 -0
- data/docs/Prismic/Fragments/WebLink.html +340 -0
- data/docs/Prismic/HtmlSerializer.html +270 -0
- data/docs/Prismic/JsonParser.html +1764 -0
- data/docs/Prismic/LinkResolver.html +399 -0
- data/docs/Prismic/LruCache.html +1140 -0
- data/docs/Prismic/Predicates.html +1630 -0
- data/docs/Prismic/Ref.html +643 -0
- data/docs/Prismic/Response.html +1159 -0
- data/docs/Prismic/SearchForm.html +2172 -0
- data/docs/Prismic/SearchForm/AuthenticationException.html +147 -0
- data/docs/Prismic/SearchForm/AuthorizationException.html +147 -0
- data/docs/Prismic/SearchForm/FormSearchException.html +147 -0
- data/docs/Prismic/SearchForm/NoRefSetException.html +147 -0
- data/docs/Prismic/SearchForm/RefNotFoundException.html +147 -0
- data/docs/Prismic/SearchForm/UnsupportedFormKind.html +147 -0
- data/docs/Prismic/Variation.html +546 -0
- data/docs/Prismic/WithFragments.html +1803 -0
- data/docs/_index.html +752 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +57 -0
- data/docs/css/style.css +339 -0
- data/docs/file.README.html +180 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +26 -0
- data/docs/index.html +180 -0
- data/docs/js/app.js +219 -0
- data/docs/js/full_list.js +178 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +2381 -0
- data/docs/top-level-namespace.html +112 -0
- data/lib/prismic.rb +17 -1
- data/lib/prismic/api.rb +31 -19
- data/lib/prismic/fragments/image.rb +6 -0
- data/lib/prismic/json_parsers.rb +2 -0
- data/lib/prismic/version.rb +1 -1
- data/spec/cache_spec.rb +12 -12
- data/spec/json_parsers_spec.rb +10 -5
- data/spec/oauth_spec.rb +3 -3
- data/spec/prismic_spec.rb +7 -7
- data/spec/responses_mocks/api.json +12 -12
- data/spec/responses_mocks/document.json +4 -2
- data/spec/responses_mocks/document_with_unknown_fragment.json +2 -0
- data/spec/responses_mocks/fragments.json +5 -3
- data/spec/responses_mocks/slices.json +2 -0
- data/spec/responses_mocks/structured_text_with_labels.json +2 -2
- data/spec/simple_search_spec.rb +55 -0
- metadata +103 -24
- data/deploy-doc.sh +0 -9
- data/spec/doc_spec.rb +0 -298
- data/spec/lesbonneschoses_spec.rb +0 -228
@@ -0,0 +1,399 @@
|
|
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: Prismic::LinkResolver
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" 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#!Prismic/LinkResolver.html";
|
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 (L)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Prismic.html" title="Prismic (module)">Prismic</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">LinkResolver</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: Prismic::LinkResolver
|
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">Prismic::LinkResolver</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/prismic.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
<p>The LinkResolver will help to build URL specific to an application, based
|
105
|
+
on a generic prismic.io's <span class='object_link'><a href="Fragments/DocumentLink.html" title="Prismic::Fragments::DocumentLink (class)">Document link</a></span>.</p>
|
106
|
+
|
107
|
+
<p>The <span class='object_link'><a href="../Prismic.html#link_resolver-class_method" title="Prismic.link_resolver (method)">link_resolver</a></span> function is the recommended way to create a LinkResolver.</p>
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div class="tags">
|
113
|
+
|
114
|
+
|
115
|
+
</div>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
120
|
+
<ul class="summary">
|
121
|
+
|
122
|
+
<li class="public ">
|
123
|
+
<span class="summary_signature">
|
124
|
+
|
125
|
+
<a href="#ref-instance_method" title="#ref (instance method)">- (Object) <strong>ref</strong> </a>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
</span>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<span class="note title readonly">readonly</span>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute ref.</p>
|
145
|
+
</div></span>
|
146
|
+
|
147
|
+
</li>
|
148
|
+
|
149
|
+
|
150
|
+
</ul>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<h2>
|
157
|
+
Instance Method Summary
|
158
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
159
|
+
</h2>
|
160
|
+
|
161
|
+
<ul class="summary">
|
162
|
+
|
163
|
+
<li class="public ">
|
164
|
+
<span class="summary_signature">
|
165
|
+
|
166
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (LinkResolver) <strong>initialize</strong>(ref) {|doc_link| ... }</a>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</span>
|
171
|
+
|
172
|
+
|
173
|
+
<span class="note title constructor">constructor</span>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of LinkResolver.</p>
|
183
|
+
</div></span>
|
184
|
+
|
185
|
+
</li>
|
186
|
+
|
187
|
+
|
188
|
+
<li class="public ">
|
189
|
+
<span class="summary_signature">
|
190
|
+
|
191
|
+
<a href="#link_to-instance_method" title="#link_to (instance method)">- (Object) <strong>link_to</strong>(doc) </a>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
</span>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
206
|
+
|
207
|
+
</li>
|
208
|
+
|
209
|
+
|
210
|
+
</ul>
|
211
|
+
|
212
|
+
|
213
|
+
<div id="constructor_details" class="method_details_list">
|
214
|
+
<h2>Constructor Details</h2>
|
215
|
+
|
216
|
+
<div class="method_details first">
|
217
|
+
<h3 class="signature first" id="initialize-instance_method">
|
218
|
+
|
219
|
+
- (<tt><span class='object_link'><a href="" title="Prismic::LinkResolver (class)">LinkResolver</a></span></tt>) <strong>initialize</strong>(ref) {|doc_link| ... }
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</h3><div class="docstring">
|
226
|
+
<div class="discussion">
|
227
|
+
<p>Returns a new instance of LinkResolver</p>
|
228
|
+
|
229
|
+
|
230
|
+
</div>
|
231
|
+
</div>
|
232
|
+
<div class="tags">
|
233
|
+
|
234
|
+
<p class="tag_title">Yield Parameters:</p>
|
235
|
+
<ul class="yieldparam">
|
236
|
+
|
237
|
+
<li>
|
238
|
+
|
239
|
+
<span class='name'>doc_link</span>
|
240
|
+
|
241
|
+
|
242
|
+
<span class='type'>(<tt><span class='object_link'><a href="Fragments/DocumentLink.html" title="Prismic::Fragments::DocumentLink (class)">Fragments::DocumentLink</a></span></tt>)</span>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
—
|
247
|
+
<div class='inline'><p>A DocumentLink instance</p>
|
248
|
+
</div>
|
249
|
+
|
250
|
+
</li>
|
251
|
+
|
252
|
+
</ul>
|
253
|
+
<p class="tag_title">Yield Returns:</p>
|
254
|
+
<ul class="yieldreturn">
|
255
|
+
|
256
|
+
<li>
|
257
|
+
|
258
|
+
|
259
|
+
<span class='type'>(<tt>String</tt>)</span>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
—
|
264
|
+
<div class='inline'><p>The application specific URL of the given document</p>
|
265
|
+
</div>
|
266
|
+
|
267
|
+
</li>
|
268
|
+
|
269
|
+
</ul>
|
270
|
+
|
271
|
+
</div><table class="source_code">
|
272
|
+
<tr>
|
273
|
+
<td>
|
274
|
+
<pre class="lines">
|
275
|
+
|
276
|
+
|
277
|
+
528
|
278
|
+
529
|
279
|
+
530
|
280
|
+
531</pre>
|
281
|
+
</td>
|
282
|
+
<td>
|
283
|
+
<pre class="code"><span class="info file"># File 'lib/prismic.rb', line 528</span>
|
284
|
+
|
285
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_ref'>ref</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
286
|
+
<span class='ivar'>@ref</span> <span class='op'>=</span> <span class='id identifier rubyid_ref'>ref</span>
|
287
|
+
<span class='ivar'>@blk</span> <span class='op'>=</span> <span class='id identifier rubyid_blk'>blk</span>
|
288
|
+
<span class='kw'>end</span></pre>
|
289
|
+
</td>
|
290
|
+
</tr>
|
291
|
+
</table>
|
292
|
+
</div>
|
293
|
+
|
294
|
+
</div>
|
295
|
+
|
296
|
+
<div id="instance_attr_details" class="attr_details">
|
297
|
+
<h2>Instance Attribute Details</h2>
|
298
|
+
|
299
|
+
|
300
|
+
<span id=""></span>
|
301
|
+
<div class="method_details first">
|
302
|
+
<h3 class="signature first" id="ref-instance_method">
|
303
|
+
|
304
|
+
- (<tt>Object</tt>) <strong>ref</strong> <span class="extras">(readonly)</span>
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
</h3><div class="docstring">
|
311
|
+
<div class="discussion">
|
312
|
+
<p>Returns the value of attribute ref</p>
|
313
|
+
|
314
|
+
|
315
|
+
</div>
|
316
|
+
</div>
|
317
|
+
<div class="tags">
|
318
|
+
|
319
|
+
|
320
|
+
</div><table class="source_code">
|
321
|
+
<tr>
|
322
|
+
<td>
|
323
|
+
<pre class="lines">
|
324
|
+
|
325
|
+
|
326
|
+
524
|
327
|
+
525
|
328
|
+
526</pre>
|
329
|
+
</td>
|
330
|
+
<td>
|
331
|
+
<pre class="code"><span class="info file"># File 'lib/prismic.rb', line 524</span>
|
332
|
+
|
333
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ref'>ref</span>
|
334
|
+
<span class='ivar'>@ref</span>
|
335
|
+
<span class='kw'>end</span></pre>
|
336
|
+
</td>
|
337
|
+
</tr>
|
338
|
+
</table>
|
339
|
+
</div>
|
340
|
+
|
341
|
+
</div>
|
342
|
+
|
343
|
+
|
344
|
+
<div id="instance_method_details" class="method_details_list">
|
345
|
+
<h2>Instance Method Details</h2>
|
346
|
+
|
347
|
+
|
348
|
+
<div class="method_details first">
|
349
|
+
<h3 class="signature first" id="link_to-instance_method">
|
350
|
+
|
351
|
+
- (<tt>Object</tt>) <strong>link_to</strong>(doc)
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
</h3><table class="source_code">
|
358
|
+
<tr>
|
359
|
+
<td>
|
360
|
+
<pre class="lines">
|
361
|
+
|
362
|
+
|
363
|
+
532
|
364
|
+
533
|
365
|
+
534
|
366
|
+
535
|
367
|
+
536
|
368
|
+
537
|
369
|
+
538
|
370
|
+
539</pre>
|
371
|
+
</td>
|
372
|
+
<td>
|
373
|
+
<pre class="code"><span class="info file"># File 'lib/prismic.rb', line 532</span>
|
374
|
+
|
375
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_link_to'>link_to</span><span class='lparen'>(</span><span class='id identifier rubyid_doc'>doc</span><span class='rparen'>)</span>
|
376
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Prismic</span><span class='op'>::</span><span class='const'>Fragments</span><span class='op'>::</span><span class='const'>DocumentLink</span>
|
377
|
+
<span class='ivar'>@blk</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_doc'>doc</span><span class='rparen'>)</span>
|
378
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Prismic</span><span class='op'>::</span><span class='const'>Document</span>
|
379
|
+
<span class='id identifier rubyid_doc_link'>doc_link</span> <span class='op'>=</span> <span class='const'>Prismic</span><span class='op'>::</span><span class='const'>Fragments</span><span class='op'>::</span><span class='const'>DocumentLink</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_uid'>uid</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_tags'>tags</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_slug'>slug</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_fragments'>fragments</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
380
|
+
<span class='ivar'>@blk</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_doc_link'>doc_link</span><span class='rparen'>)</span>
|
381
|
+
<span class='kw'>end</span>
|
382
|
+
<span class='kw'>end</span></pre>
|
383
|
+
</td>
|
384
|
+
</tr>
|
385
|
+
</table>
|
386
|
+
</div>
|
387
|
+
|
388
|
+
</div>
|
389
|
+
|
390
|
+
</div>
|
391
|
+
|
392
|
+
<div id="footer">
|
393
|
+
Generated on Tue Sep 27 10:47:06 2016 by
|
394
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
395
|
+
0.8.7.4 (ruby-2.0.0).
|
396
|
+
</div>
|
397
|
+
|
398
|
+
</body>
|
399
|
+
</html>
|
@@ -0,0 +1,1140 @@
|
|
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: Prismic::LruCache
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" 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#!Prismic/LruCache.html";
|
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 (L)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Prismic.html" title="Prismic (module)">Prismic</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">LruCache</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: Prismic::LruCache
|
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">Prismic::LruCache</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/prismic/cache/lru.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
<p>This is a simple cache class provided with the prismic.io Ruby kit.</p>
|
105
|
+
|
106
|
+
<p>It is pretty dumb but effective: * everything is stored in memory,</p>
|
107
|
+
|
108
|
+
<p>If you need a smarter caching (for instance, rely on memcached), you can
|
109
|
+
extend this class and replace its methods, and when creating your API object
|
110
|
+
like this for instance: Prismic.api(url, options), pass the name of the
|
111
|
+
class you created as a :cache option. Therefore, to use this simple cache,
|
112
|
+
you can create your API object like this: <code>Prismic.api(url, cache:
|
113
|
+
Prismic::DefaultCache)</code></p>
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
<div class="tags">
|
119
|
+
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#intern-instance_method" title="#intern (instance method)">- (LRUHash<String,Object>) <strong>intern</strong> </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
<span class="note title readonly">readonly</span>
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
151
|
+
|
152
|
+
</li>
|
153
|
+
|
154
|
+
|
155
|
+
</ul>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<h2>
|
162
|
+
Instance Method Summary
|
163
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
164
|
+
</h2>
|
165
|
+
|
166
|
+
<ul class="summary">
|
167
|
+
|
168
|
+
<li class="public ">
|
169
|
+
<span class="summary_signature">
|
170
|
+
|
171
|
+
<a href="#%5B%5D%3D-instance_method" title="#[]= (instance method)">- (Object) <strong>[]=</strong>(key, value) </a>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
</span>
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
186
|
+
|
187
|
+
</li>
|
188
|
+
|
189
|
+
|
190
|
+
<li class="public ">
|
191
|
+
<span class="summary_signature">
|
192
|
+
|
193
|
+
<a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(key) </a>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
</span>
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
208
|
+
|
209
|
+
</li>
|
210
|
+
|
211
|
+
|
212
|
+
<li class="public ">
|
213
|
+
<span class="summary_signature">
|
214
|
+
|
215
|
+
<a href="#expired%3F-instance_method" title="#expired? (instance method)">- (Boolean) <strong>expired?</strong>(key) </a>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
</span>
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
230
|
+
|
231
|
+
</li>
|
232
|
+
|
233
|
+
|
234
|
+
<li class="public ">
|
235
|
+
<span class="summary_signature">
|
236
|
+
|
237
|
+
<a href="#get-instance_method" title="#get (instance method)">- (Object) <strong>get</strong>(key) </a>
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
(also: #[])
|
242
|
+
|
243
|
+
</span>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
<span class="summary_desc"><div class='inline'><p>Get a cache entry.</p>
|
254
|
+
</div></span>
|
255
|
+
|
256
|
+
</li>
|
257
|
+
|
258
|
+
|
259
|
+
<li class="public ">
|
260
|
+
<span class="summary_signature">
|
261
|
+
|
262
|
+
<a href="#get_or_set-instance_method" title="#get_or_set (instance method)">- (Object) <strong>get_or_set</strong>(key, value = nil, expired_in = nil) </a>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
</span>
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
277
|
+
|
278
|
+
</li>
|
279
|
+
|
280
|
+
|
281
|
+
<li class="public ">
|
282
|
+
<span class="summary_signature">
|
283
|
+
|
284
|
+
<a href="#has_key%3F-instance_method" title="#has_key? (instance method)">- (Boolean) <strong>has_key?</strong>(key) </a>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
(also: #include?)
|
289
|
+
|
290
|
+
</span>
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
<span class="summary_desc"><div class='inline'><p>Checks if a cache entry exists.</p>
|
301
|
+
</div></span>
|
302
|
+
|
303
|
+
</li>
|
304
|
+
|
305
|
+
|
306
|
+
<li class="public ">
|
307
|
+
<span class="summary_signature">
|
308
|
+
|
309
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (LruCache) <strong>initialize</strong>(max_size = 100) </a>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
</span>
|
314
|
+
|
315
|
+
|
316
|
+
<span class="note title constructor">constructor</span>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of LruCache.</p>
|
326
|
+
</div></span>
|
327
|
+
|
328
|
+
</li>
|
329
|
+
|
330
|
+
|
331
|
+
<li class="public ">
|
332
|
+
<span class="summary_signature">
|
333
|
+
|
334
|
+
<a href="#invalidate_all%21-instance_method" title="#invalidate_all! (instance method)">- (Object) <strong>invalidate_all!</strong> </a>
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
(also: #clear!)
|
339
|
+
|
340
|
+
</span>
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
<span class="summary_desc"><div class='inline'><p>Invalidates all entries.</p>
|
351
|
+
</div></span>
|
352
|
+
|
353
|
+
</li>
|
354
|
+
|
355
|
+
|
356
|
+
<li class="public ">
|
357
|
+
<span class="summary_signature">
|
358
|
+
|
359
|
+
<a href="#keys-instance_method" title="#keys (instance method)">- (Array<String>) <strong>keys</strong> </a>
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
</span>
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
<span class="summary_desc"><div class='inline'><p>Expose the Hash keys.</p>
|
374
|
+
</div></span>
|
375
|
+
|
376
|
+
</li>
|
377
|
+
|
378
|
+
|
379
|
+
<li class="public ">
|
380
|
+
<span class="summary_signature">
|
381
|
+
|
382
|
+
<a href="#set-instance_method" title="#set (instance method)">- (Object) <strong>set</strong>(key, value, expired_in = nil) </a>
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
</span>
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
<span class="summary_desc"><div class='inline'><p>Add a cache entry.</p>
|
397
|
+
</div></span>
|
398
|
+
|
399
|
+
</li>
|
400
|
+
|
401
|
+
|
402
|
+
<li class="public ">
|
403
|
+
<span class="summary_signature">
|
404
|
+
|
405
|
+
<a href="#size-instance_method" title="#size (instance method)">- (Fixum) <strong>size</strong> </a>
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
(also: #length)
|
410
|
+
|
411
|
+
</span>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
<span class="summary_desc"><div class='inline'><p>Return the number of stored keys.</p>
|
422
|
+
</div></span>
|
423
|
+
|
424
|
+
</li>
|
425
|
+
|
426
|
+
|
427
|
+
</ul>
|
428
|
+
|
429
|
+
|
430
|
+
<div id="constructor_details" class="method_details_list">
|
431
|
+
<h2>Constructor Details</h2>
|
432
|
+
|
433
|
+
<div class="method_details first">
|
434
|
+
<h3 class="signature first" id="initialize-instance_method">
|
435
|
+
|
436
|
+
- (<tt><span class='object_link'><a href="" title="Prismic::LruCache (class)">LruCache</a></span></tt>) <strong>initialize</strong>(max_size = 100)
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
</h3><div class="docstring">
|
443
|
+
<div class="discussion">
|
444
|
+
<p>Returns a new instance of LruCache</p>
|
445
|
+
|
446
|
+
|
447
|
+
</div>
|
448
|
+
</div>
|
449
|
+
<div class="tags">
|
450
|
+
<p class="tag_title">Parameters:</p>
|
451
|
+
<ul class="param">
|
452
|
+
|
453
|
+
<li>
|
454
|
+
|
455
|
+
<span class='name'>max_size</span>
|
456
|
+
|
457
|
+
|
458
|
+
<span class='type'>(<tt>Fixnum</tt>)</span>
|
459
|
+
|
460
|
+
|
461
|
+
<em class="default">(defaults to: <tt>100</tt>)</em>
|
462
|
+
|
463
|
+
|
464
|
+
—
|
465
|
+
<div class='inline'><p>(100) The default maximum of keys to store</p>
|
466
|
+
</div>
|
467
|
+
|
468
|
+
</li>
|
469
|
+
|
470
|
+
</ul>
|
471
|
+
|
472
|
+
|
473
|
+
</div><table class="source_code">
|
474
|
+
<tr>
|
475
|
+
<td>
|
476
|
+
<pre class="lines">
|
477
|
+
|
478
|
+
|
479
|
+
22
|
480
|
+
23
|
481
|
+
24</pre>
|
482
|
+
</td>
|
483
|
+
<td>
|
484
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 22</span>
|
485
|
+
|
486
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_max_size'>max_size</span><span class='op'>=</span><span class='int'>100</span><span class='rparen'>)</span>
|
487
|
+
<span class='ivar'>@intern</span> <span class='op'>=</span> <span class='const'>Hashery</span><span class='op'>::</span><span class='const'>LRUHash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_max_size'>max_size</span><span class='rparen'>)</span>
|
488
|
+
<span class='kw'>end</span></pre>
|
489
|
+
</td>
|
490
|
+
</tr>
|
491
|
+
</table>
|
492
|
+
</div>
|
493
|
+
|
494
|
+
</div>
|
495
|
+
|
496
|
+
<div id="instance_attr_details" class="attr_details">
|
497
|
+
<h2>Instance Attribute Details</h2>
|
498
|
+
|
499
|
+
|
500
|
+
<span id=""></span>
|
501
|
+
<div class="method_details first">
|
502
|
+
<h3 class="signature first" id="intern-instance_method">
|
503
|
+
|
504
|
+
- (<tt>LRUHash<String,Object></tt>) <strong>intern</strong> <span class="extras">(readonly)</span>
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
</h3><div class="docstring">
|
511
|
+
<div class="discussion">
|
512
|
+
|
513
|
+
|
514
|
+
</div>
|
515
|
+
</div>
|
516
|
+
<div class="tags">
|
517
|
+
|
518
|
+
<p class="tag_title">Returns:</p>
|
519
|
+
<ul class="return">
|
520
|
+
|
521
|
+
<li>
|
522
|
+
|
523
|
+
|
524
|
+
<span class='type'>(<tt>LRUHash<String,Object></tt>)</span>
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
</li>
|
529
|
+
|
530
|
+
</ul>
|
531
|
+
|
532
|
+
</div><table class="source_code">
|
533
|
+
<tr>
|
534
|
+
<td>
|
535
|
+
<pre class="lines">
|
536
|
+
|
537
|
+
|
538
|
+
19
|
539
|
+
20
|
540
|
+
21</pre>
|
541
|
+
</td>
|
542
|
+
<td>
|
543
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 19</span>
|
544
|
+
|
545
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_intern'>intern</span>
|
546
|
+
<span class='ivar'>@intern</span>
|
547
|
+
<span class='kw'>end</span></pre>
|
548
|
+
</td>
|
549
|
+
</tr>
|
550
|
+
</table>
|
551
|
+
</div>
|
552
|
+
|
553
|
+
</div>
|
554
|
+
|
555
|
+
|
556
|
+
<div id="instance_method_details" class="method_details_list">
|
557
|
+
<h2>Instance Method Details</h2>
|
558
|
+
|
559
|
+
|
560
|
+
<div class="method_details first">
|
561
|
+
<h3 class="signature first" id="[]=-instance_method">
|
562
|
+
|
563
|
+
- (<tt>Object</tt>) <strong>[]=</strong>(key, value)
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
</h3><table class="source_code">
|
570
|
+
<tr>
|
571
|
+
<td>
|
572
|
+
<pre class="lines">
|
573
|
+
|
574
|
+
|
575
|
+
37
|
576
|
+
38
|
577
|
+
39</pre>
|
578
|
+
</td>
|
579
|
+
<td>
|
580
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 37</span>
|
581
|
+
|
582
|
+
<span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
583
|
+
<span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
584
|
+
<span class='kw'>end</span></pre>
|
585
|
+
</td>
|
586
|
+
</tr>
|
587
|
+
</table>
|
588
|
+
</div>
|
589
|
+
|
590
|
+
<div class="method_details ">
|
591
|
+
<h3 class="signature " id="delete-instance_method">
|
592
|
+
|
593
|
+
- (<tt>Object</tt>) <strong>delete</strong>(key)
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
</h3><table class="source_code">
|
600
|
+
<tr>
|
601
|
+
<td>
|
602
|
+
<pre class="lines">
|
603
|
+
|
604
|
+
|
605
|
+
60
|
606
|
+
61
|
607
|
+
62
|
608
|
+
63</pre>
|
609
|
+
</td>
|
610
|
+
<td>
|
611
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 60</span>
|
612
|
+
|
613
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
614
|
+
<span class='ivar'>@intern</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
615
|
+
<span class='kw'>nil</span>
|
616
|
+
<span class='kw'>end</span></pre>
|
617
|
+
</td>
|
618
|
+
</tr>
|
619
|
+
</table>
|
620
|
+
</div>
|
621
|
+
|
622
|
+
<div class="method_details ">
|
623
|
+
<h3 class="signature " id="expired?-instance_method">
|
624
|
+
|
625
|
+
- (<tt>Boolean</tt>) <strong>expired?</strong>(key)
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
</h3><div class="docstring">
|
632
|
+
<div class="discussion">
|
633
|
+
|
634
|
+
|
635
|
+
</div>
|
636
|
+
</div>
|
637
|
+
<div class="tags">
|
638
|
+
|
639
|
+
<p class="tag_title">Returns:</p>
|
640
|
+
<ul class="return">
|
641
|
+
|
642
|
+
<li>
|
643
|
+
|
644
|
+
|
645
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
</li>
|
650
|
+
|
651
|
+
</ul>
|
652
|
+
|
653
|
+
</div><table class="source_code">
|
654
|
+
<tr>
|
655
|
+
<td>
|
656
|
+
<pre class="lines">
|
657
|
+
|
658
|
+
|
659
|
+
75
|
660
|
+
76
|
661
|
+
77
|
662
|
+
78
|
663
|
+
79
|
664
|
+
80
|
665
|
+
81
|
666
|
+
82</pre>
|
667
|
+
</td>
|
668
|
+
<td>
|
669
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 75</span>
|
670
|
+
|
671
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_expired?'>expired?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
672
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='ivar'>@intern</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:expired_in</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='kw'>nil</span>
|
673
|
+
<span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'>=</span> <span class='ivar'>@intern</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:expired_in</span><span class='rbracket'>]</span>
|
674
|
+
<span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'>&&</span> <span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'><</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_getutc'>getutc</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
|
675
|
+
<span class='kw'>else</span>
|
676
|
+
<span class='kw'>false</span>
|
677
|
+
<span class='kw'>end</span>
|
678
|
+
<span class='kw'>end</span></pre>
|
679
|
+
</td>
|
680
|
+
</tr>
|
681
|
+
</table>
|
682
|
+
</div>
|
683
|
+
|
684
|
+
<div class="method_details ">
|
685
|
+
<h3 class="signature " id="get-instance_method">
|
686
|
+
|
687
|
+
- (<tt>Object</tt>) <strong>get</strong>(key)
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
<span class="aliases">Also known as:
|
692
|
+
<span class="names"><span id='[]-instance_method'>[]</span></span>
|
693
|
+
</span>
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
</h3><div class="docstring">
|
698
|
+
<div class="discussion">
|
699
|
+
<p>Get a cache entry</p>
|
700
|
+
|
701
|
+
|
702
|
+
</div>
|
703
|
+
</div>
|
704
|
+
<div class="tags">
|
705
|
+
<p class="tag_title">Parameters:</p>
|
706
|
+
<ul class="param">
|
707
|
+
|
708
|
+
<li>
|
709
|
+
|
710
|
+
<span class='name'>key</span>
|
711
|
+
|
712
|
+
|
713
|
+
<span class='type'>(<tt>String</tt>)</span>
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
—
|
718
|
+
<div class='inline'><p>The key to fetch</p>
|
719
|
+
</div>
|
720
|
+
|
721
|
+
</li>
|
722
|
+
|
723
|
+
</ul>
|
724
|
+
|
725
|
+
<p class="tag_title">Returns:</p>
|
726
|
+
<ul class="return">
|
727
|
+
|
728
|
+
<li>
|
729
|
+
|
730
|
+
|
731
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
732
|
+
|
733
|
+
|
734
|
+
|
735
|
+
—
|
736
|
+
<div class='inline'><p>The cache object as was stored</p>
|
737
|
+
</div>
|
738
|
+
|
739
|
+
</li>
|
740
|
+
|
741
|
+
</ul>
|
742
|
+
|
743
|
+
</div><table class="source_code">
|
744
|
+
<tr>
|
745
|
+
<td>
|
746
|
+
<pre class="lines">
|
747
|
+
|
748
|
+
|
749
|
+
46
|
750
|
+
47
|
751
|
+
48
|
752
|
+
49</pre>
|
753
|
+
</td>
|
754
|
+
<td>
|
755
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 46</span>
|
756
|
+
|
757
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
758
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_expired?'>expired?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
759
|
+
<span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='ivar'>@intern</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='kw'>nil</span>
|
760
|
+
<span class='kw'>end</span></pre>
|
761
|
+
</td>
|
762
|
+
</tr>
|
763
|
+
</table>
|
764
|
+
</div>
|
765
|
+
|
766
|
+
<div class="method_details ">
|
767
|
+
<h3 class="signature " id="get_or_set-instance_method">
|
768
|
+
|
769
|
+
- (<tt>Object</tt>) <strong>get_or_set</strong>(key, value = nil, expired_in = nil)
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
|
774
|
+
|
775
|
+
</h3><table class="source_code">
|
776
|
+
<tr>
|
777
|
+
<td>
|
778
|
+
<pre class="lines">
|
779
|
+
|
780
|
+
|
781
|
+
52
|
782
|
+
53
|
783
|
+
54
|
784
|
+
55
|
785
|
+
56
|
786
|
+
57
|
787
|
+
58</pre>
|
788
|
+
</td>
|
789
|
+
<td>
|
790
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 52</span>
|
791
|
+
|
792
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_or_set'>get_or_set</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
793
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_expired?'>expired?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
794
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
795
|
+
<span class='kw'>else</span>
|
796
|
+
<span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_block_given?'>block_given?</span> <span class='op'>?</span> <span class='kw'>yield</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_expired_in'>expired_in</span><span class='rparen'>)</span>
|
797
|
+
<span class='kw'>end</span>
|
798
|
+
<span class='kw'>end</span></pre>
|
799
|
+
</td>
|
800
|
+
</tr>
|
801
|
+
</table>
|
802
|
+
</div>
|
803
|
+
|
804
|
+
<div class="method_details ">
|
805
|
+
<h3 class="signature " id="has_key?-instance_method">
|
806
|
+
|
807
|
+
- (<tt>Boolean</tt>) <strong>has_key?</strong>(key)
|
808
|
+
|
809
|
+
|
810
|
+
|
811
|
+
<span class="aliases">Also known as:
|
812
|
+
<span class="names"><span id='include?-instance_method'>include?</span></span>
|
813
|
+
</span>
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
</h3><div class="docstring">
|
818
|
+
<div class="discussion">
|
819
|
+
<p>Checks if a cache entry exists</p>
|
820
|
+
|
821
|
+
|
822
|
+
</div>
|
823
|
+
</div>
|
824
|
+
<div class="tags">
|
825
|
+
<p class="tag_title">Parameters:</p>
|
826
|
+
<ul class="param">
|
827
|
+
|
828
|
+
<li>
|
829
|
+
|
830
|
+
<span class='name'>key</span>
|
831
|
+
|
832
|
+
|
833
|
+
<span class='type'>(<tt>String</tt>)</span>
|
834
|
+
|
835
|
+
|
836
|
+
|
837
|
+
—
|
838
|
+
<div class='inline'><p>The key to test</p>
|
839
|
+
</div>
|
840
|
+
|
841
|
+
</li>
|
842
|
+
|
843
|
+
</ul>
|
844
|
+
|
845
|
+
<p class="tag_title">Returns:</p>
|
846
|
+
<ul class="return">
|
847
|
+
|
848
|
+
<li>
|
849
|
+
|
850
|
+
|
851
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
</li>
|
856
|
+
|
857
|
+
</ul>
|
858
|
+
|
859
|
+
</div><table class="source_code">
|
860
|
+
<tr>
|
861
|
+
<td>
|
862
|
+
<pre class="lines">
|
863
|
+
|
864
|
+
|
865
|
+
70
|
866
|
+
71
|
867
|
+
72</pre>
|
868
|
+
</td>
|
869
|
+
<td>
|
870
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 70</span>
|
871
|
+
|
872
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
873
|
+
<span class='ivar'>@intern</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
874
|
+
<span class='kw'>end</span></pre>
|
875
|
+
</td>
|
876
|
+
</tr>
|
877
|
+
</table>
|
878
|
+
</div>
|
879
|
+
|
880
|
+
<div class="method_details ">
|
881
|
+
<h3 class="signature " id="invalidate_all!-instance_method">
|
882
|
+
|
883
|
+
- (<tt>Object</tt>) <strong>invalidate_all!</strong>
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
<span class="aliases">Also known as:
|
888
|
+
<span class="names"><span id='clear!-instance_method'>clear!</span></span>
|
889
|
+
</span>
|
890
|
+
|
891
|
+
|
892
|
+
|
893
|
+
</h3><div class="docstring">
|
894
|
+
<div class="discussion">
|
895
|
+
<p>Invalidates all entries</p>
|
896
|
+
|
897
|
+
|
898
|
+
</div>
|
899
|
+
</div>
|
900
|
+
<div class="tags">
|
901
|
+
|
902
|
+
|
903
|
+
</div><table class="source_code">
|
904
|
+
<tr>
|
905
|
+
<td>
|
906
|
+
<pre class="lines">
|
907
|
+
|
908
|
+
|
909
|
+
85
|
910
|
+
86
|
911
|
+
87</pre>
|
912
|
+
</td>
|
913
|
+
<td>
|
914
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 85</span>
|
915
|
+
|
916
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_invalidate_all!'>invalidate_all!</span>
|
917
|
+
<span class='ivar'>@intern</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
|
918
|
+
<span class='kw'>end</span></pre>
|
919
|
+
</td>
|
920
|
+
</tr>
|
921
|
+
</table>
|
922
|
+
</div>
|
923
|
+
|
924
|
+
<div class="method_details ">
|
925
|
+
<h3 class="signature " id="keys-instance_method">
|
926
|
+
|
927
|
+
- (<tt>Array<String></tt>) <strong>keys</strong>
|
928
|
+
|
929
|
+
|
930
|
+
|
931
|
+
|
932
|
+
|
933
|
+
</h3><div class="docstring">
|
934
|
+
<div class="discussion">
|
935
|
+
<p>Expose the Hash keys</p>
|
936
|
+
|
937
|
+
<p>This is only for debugging purposes.</p>
|
938
|
+
|
939
|
+
|
940
|
+
</div>
|
941
|
+
</div>
|
942
|
+
<div class="tags">
|
943
|
+
|
944
|
+
<p class="tag_title">Returns:</p>
|
945
|
+
<ul class="return">
|
946
|
+
|
947
|
+
<li>
|
948
|
+
|
949
|
+
|
950
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
951
|
+
|
952
|
+
|
953
|
+
|
954
|
+
</li>
|
955
|
+
|
956
|
+
</ul>
|
957
|
+
|
958
|
+
</div><table class="source_code">
|
959
|
+
<tr>
|
960
|
+
<td>
|
961
|
+
<pre class="lines">
|
962
|
+
|
963
|
+
|
964
|
+
95
|
965
|
+
96
|
966
|
+
97</pre>
|
967
|
+
</td>
|
968
|
+
<td>
|
969
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 95</span>
|
970
|
+
|
971
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_keys'>keys</span>
|
972
|
+
<span class='ivar'>@intern</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
|
973
|
+
<span class='kw'>end</span></pre>
|
974
|
+
</td>
|
975
|
+
</tr>
|
976
|
+
</table>
|
977
|
+
</div>
|
978
|
+
|
979
|
+
<div class="method_details ">
|
980
|
+
<h3 class="signature " id="set-instance_method">
|
981
|
+
|
982
|
+
- (<tt>Object</tt>) <strong>set</strong>(key, value, expired_in = nil)
|
983
|
+
|
984
|
+
|
985
|
+
|
986
|
+
|
987
|
+
|
988
|
+
</h3><div class="docstring">
|
989
|
+
<div class="discussion">
|
990
|
+
<p>Add a cache entry.</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'>key</span>
|
1002
|
+
|
1003
|
+
|
1004
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1005
|
+
|
1006
|
+
|
1007
|
+
|
1008
|
+
—
|
1009
|
+
<div class='inline'><p>The key</p>
|
1010
|
+
</div>
|
1011
|
+
|
1012
|
+
</li>
|
1013
|
+
|
1014
|
+
<li>
|
1015
|
+
|
1016
|
+
<span class='name'>value</span>
|
1017
|
+
|
1018
|
+
|
1019
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
1020
|
+
|
1021
|
+
|
1022
|
+
|
1023
|
+
—
|
1024
|
+
<div class='inline'><p>The value to store</p>
|
1025
|
+
</div>
|
1026
|
+
|
1027
|
+
</li>
|
1028
|
+
|
1029
|
+
</ul>
|
1030
|
+
|
1031
|
+
<p class="tag_title">Returns:</p>
|
1032
|
+
<ul class="return">
|
1033
|
+
|
1034
|
+
<li>
|
1035
|
+
|
1036
|
+
|
1037
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
1038
|
+
|
1039
|
+
|
1040
|
+
|
1041
|
+
—
|
1042
|
+
<div class='inline'><p>The stored value</p>
|
1043
|
+
</div>
|
1044
|
+
|
1045
|
+
</li>
|
1046
|
+
|
1047
|
+
</ul>
|
1048
|
+
|
1049
|
+
</div><table class="source_code">
|
1050
|
+
<tr>
|
1051
|
+
<td>
|
1052
|
+
<pre class="lines">
|
1053
|
+
|
1054
|
+
|
1055
|
+
32
|
1056
|
+
33
|
1057
|
+
34
|
1058
|
+
35</pre>
|
1059
|
+
</td>
|
1060
|
+
<td>
|
1061
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 32</span>
|
1062
|
+
|
1063
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1064
|
+
<span class='ivar'>@intern</span><span class='period'>.</span><span class='id identifier rubyid_store'>store</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:data</span> <span class='op'>=></span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='symbol'>:expired_in</span> <span class='op'>=></span> <span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'>=</span> <span class='id identifier rubyid_expired_in'>expired_in</span> <span class='op'>&&</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_getutc'>getutc</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='id identifier rubyid_expired_in'>expired_in</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
1065
|
+
<span class='id identifier rubyid_value'>value</span>
|
1066
|
+
<span class='kw'>end</span></pre>
|
1067
|
+
</td>
|
1068
|
+
</tr>
|
1069
|
+
</table>
|
1070
|
+
</div>
|
1071
|
+
|
1072
|
+
<div class="method_details ">
|
1073
|
+
<h3 class="signature " id="size-instance_method">
|
1074
|
+
|
1075
|
+
- (<tt>Fixum</tt>) <strong>size</strong>
|
1076
|
+
|
1077
|
+
|
1078
|
+
|
1079
|
+
<span class="aliases">Also known as:
|
1080
|
+
<span class="names"><span id='length-instance_method'>length</span></span>
|
1081
|
+
</span>
|
1082
|
+
|
1083
|
+
|
1084
|
+
|
1085
|
+
</h3><div class="docstring">
|
1086
|
+
<div class="discussion">
|
1087
|
+
<p>Return the number of stored keys</p>
|
1088
|
+
|
1089
|
+
|
1090
|
+
</div>
|
1091
|
+
</div>
|
1092
|
+
<div class="tags">
|
1093
|
+
|
1094
|
+
<p class="tag_title">Returns:</p>
|
1095
|
+
<ul class="return">
|
1096
|
+
|
1097
|
+
<li>
|
1098
|
+
|
1099
|
+
|
1100
|
+
<span class='type'>(<tt>Fixum</tt>)</span>
|
1101
|
+
|
1102
|
+
|
1103
|
+
|
1104
|
+
</li>
|
1105
|
+
|
1106
|
+
</ul>
|
1107
|
+
|
1108
|
+
</div><table class="source_code">
|
1109
|
+
<tr>
|
1110
|
+
<td>
|
1111
|
+
<pre class="lines">
|
1112
|
+
|
1113
|
+
|
1114
|
+
102
|
1115
|
+
103
|
1116
|
+
104</pre>
|
1117
|
+
</td>
|
1118
|
+
<td>
|
1119
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/cache/lru.rb', line 102</span>
|
1120
|
+
|
1121
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
1122
|
+
<span class='ivar'>@intern</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
|
1123
|
+
<span class='kw'>end</span></pre>
|
1124
|
+
</td>
|
1125
|
+
</tr>
|
1126
|
+
</table>
|
1127
|
+
</div>
|
1128
|
+
|
1129
|
+
</div>
|
1130
|
+
|
1131
|
+
</div>
|
1132
|
+
|
1133
|
+
<div id="footer">
|
1134
|
+
Generated on Tue Sep 27 10:47:06 2016 by
|
1135
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1136
|
+
0.8.7.4 (ruby-2.0.0).
|
1137
|
+
</div>
|
1138
|
+
|
1139
|
+
</body>
|
1140
|
+
</html>
|