contentful 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/ChangeLog.md +6 -0
  4. data/Gemfile +5 -0
  5. data/README.md +1 -0
  6. data/contentful.gemspec +1 -1
  7. data/lib/contentful/array.rb +1 -2
  8. data/lib/contentful/asset.rb +3 -3
  9. data/lib/contentful/client.rb +15 -18
  10. data/lib/contentful/content_type.rb +1 -1
  11. data/lib/contentful/dynamic_entry.rb +6 -6
  12. data/lib/contentful/entry.rb +1 -1
  13. data/lib/contentful/error.rb +3 -3
  14. data/lib/contentful/field.rb +1 -1
  15. data/lib/contentful/file.rb +1 -1
  16. data/lib/contentful/link.rb +2 -2
  17. data/lib/contentful/locale.rb +1 -1
  18. data/lib/contentful/location.rb +1 -1
  19. data/lib/contentful/resource.rb +10 -11
  20. data/lib/contentful/resource_builder.rb +63 -39
  21. data/lib/contentful/space.rb +1 -1
  22. data/lib/contentful/support.rb +5 -3
  23. data/lib/contentful/version.rb +1 -1
  24. data/spec/fixtures/json_responses/includes.json +111 -0
  25. data/spec/fixtures/json_responses/link_array.json +43 -0
  26. data/spec/resource_building_spec.rb +20 -0
  27. data/spec/spec_helper.rb +5 -1
  28. metadata +138 -192
  29. data/.README.md.swp +0 -0
  30. data/do_request.sh +0 -5
  31. data/doc/Contentful.html +0 -131
  32. data/doc/Contentful/AccessDenied.html +0 -158
  33. data/doc/Contentful/Array.html +0 -346
  34. data/doc/Contentful/Asset.html +0 -315
  35. data/doc/Contentful/BadRequest.html +0 -158
  36. data/doc/Contentful/Client.html +0 -1407
  37. data/doc/Contentful/ContentType.html +0 -183
  38. data/doc/Contentful/DynamicEntry.html +0 -333
  39. data/doc/Contentful/Entry.html +0 -198
  40. data/doc/Contentful/Error.html +0 -413
  41. data/doc/Contentful/Field.html +0 -161
  42. data/doc/Contentful/File.html +0 -160
  43. data/doc/Contentful/Link.html +0 -275
  44. data/doc/Contentful/Locale.html +0 -161
  45. data/doc/Contentful/NotFound.html +0 -158
  46. data/doc/Contentful/Request.html +0 -669
  47. data/doc/Contentful/Resource.html +0 -606
  48. data/doc/Contentful/Resource/AssetFields.html +0 -413
  49. data/doc/Contentful/Resource/AssetFields/ClassMethods.html +0 -174
  50. data/doc/Contentful/Resource/ClassMethods.html +0 -271
  51. data/doc/Contentful/Resource/Fields.html +0 -398
  52. data/doc/Contentful/Resource/Fields/ClassMethods.html +0 -187
  53. data/doc/Contentful/Resource/SystemProperties.html +0 -444
  54. data/doc/Contentful/Resource/SystemProperties/ClassMethods.html +0 -174
  55. data/doc/Contentful/ResourceBuilder.html +0 -1400
  56. data/doc/Contentful/Response.html +0 -546
  57. data/doc/Contentful/ServerError.html +0 -158
  58. data/doc/Contentful/Space.html +0 -183
  59. data/doc/Contentful/Support.html +0 -198
  60. data/doc/Contentful/Unauthorized.html +0 -158
  61. data/doc/Contentful/UnparsableJson.html +0 -158
  62. data/doc/Contentful/UnparsableResource.html +0 -158
  63. data/doc/_index.html +0 -410
  64. data/doc/class_list.html +0 -54
  65. data/doc/css/common.css +0 -1
  66. data/doc/css/full_list.css +0 -57
  67. data/doc/css/style.css +0 -338
  68. data/doc/file.README.html +0 -214
  69. data/doc/file_list.html +0 -56
  70. data/doc/frames.html +0 -26
  71. data/doc/index.html +0 -214
  72. data/doc/js/app.js +0 -219
  73. data/doc/js/full_list.js +0 -178
  74. data/doc/js/jquery.js +0 -4
  75. data/doc/method_list.html +0 -533
  76. data/doc/top-level-namespace.html +0 -112
@@ -1,174 +0,0 @@
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
- Module: Contentful::Resource::SystemProperties::ClassMethods
8
-
9
- &mdash; Documentation by YARD 0.8.7.3
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#!" + 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 (C)</a> &raquo;
35
- <span class='title'><span class='object_link'><a href="../../../Contentful.html" title="Contentful (module)">Contentful</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Resource.html" title="Contentful::Resource (module)">Resource</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../SystemProperties.html" title="Contentful::Resource::SystemProperties (module)">SystemProperties</a></span></span>
36
- &raquo;
37
- <span class="title">ClassMethods</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>Module: Contentful::Resource::SystemProperties::ClassMethods
67
-
68
-
69
-
70
- </h1>
71
-
72
- <dl class="box">
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
- <dt class="r1 last">Defined in:</dt>
82
- <dd class="r1 last">lib/contentful/resource/system_properties.rb</dd>
83
-
84
- </dl>
85
- <div class="clear"></div>
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- <h2>
96
- Instance Method Summary
97
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
98
- </h2>
99
-
100
- <ul class="summary">
101
-
102
- <li class="public ">
103
- <span class="summary_signature">
104
-
105
- <a href="#sys_coercions-instance_method" title="#sys_coercions (instance method)">- (Object) <strong>sys_coercions</strong> </a>
106
-
107
-
108
-
109
- </span>
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
- <span class="summary_desc"><div class='inline'></div></span>
120
-
121
- </li>
122
-
123
-
124
- </ul>
125
-
126
-
127
-
128
-
129
- <div id="instance_method_details" class="method_details_list">
130
- <h2>Instance Method Details</h2>
131
-
132
-
133
- <div class="method_details first">
134
- <h3 class="signature first" id="sys_coercions-instance_method">
135
-
136
- - (<tt>Object</tt>) <strong>sys_coercions</strong>
137
-
138
-
139
-
140
-
141
-
142
- </h3><table class="source_code">
143
- <tr>
144
- <td>
145
- <pre class="lines">
146
-
147
-
148
- 32
149
- 33
150
- 34</pre>
151
- </td>
152
- <td>
153
- <pre class="code"><span class="info file"># File 'lib/contentful/resource/system_properties.rb', line 32</span>
154
-
155
- <span class='kw'>def</span> <span class='id identifier rubyid_sys_coercions'>sys_coercions</span>
156
- <span class='const'>SYS_COERCIONS</span>
157
- <span class='kw'>end</span></pre>
158
- </td>
159
- </tr>
160
- </table>
161
- </div>
162
-
163
- </div>
164
-
165
- </div>
166
-
167
- <div id="footer">
168
- Generated on Tue Mar 11 09:25:52 2014 by
169
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
170
- 0.8.7.3 (ruby-1.9.3).
171
- </div>
172
-
173
- </body>
174
- </html>
@@ -1,1400 +0,0 @@
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: Contentful::ResourceBuilder
8
-
9
- &mdash; Documentation by YARD 0.8.7.3
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#!" + 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 (R)</a> &raquo;
35
- <span class='title'><span class='object_link'><a href="../Contentful.html" title="Contentful (module)">Contentful</a></span></span>
36
- &raquo;
37
- <span class="title">ResourceBuilder</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: Contentful::ResourceBuilder
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">Contentful::ResourceBuilder</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/contentful/resource_builder.rb</dd>
98
-
99
- </dl>
100
- <div class="clear"></div>
101
-
102
- <h2>Overview</h2><div class="docstring">
103
- <div class="discussion">
104
-
105
- <p>Transforms a Contentful::Response into a Contentful::Resource or
106
- Contentful::Error</p>
107
-
108
-
109
- </div>
110
- </div>
111
- <div class="tags">
112
-
113
-
114
- </div>
115
- <h2>Constant Summary</h2>
116
-
117
- <dl class="constants">
118
-
119
- <dt id="DEFAULT_RESOURCE_MAPPING-constant" class="">DEFAULT_RESOURCE_MAPPING =
120
-
121
- </dt>
122
- <dd><pre class="code"><span class='lbrace'>{</span>
123
- <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Space</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='const'>Space</span><span class='comma'>,</span>
124
- <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ContentType</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='const'>ContentType</span><span class='comma'>,</span>
125
- <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Entry</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='symbol'>:try_dynamic_entry</span><span class='comma'>,</span>
126
- <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Asset</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='const'>Asset</span><span class='comma'>,</span>
127
- <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Array</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='const'>Array</span><span class='comma'>,</span>
128
- <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Link</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='const'>Link</span><span class='comma'>,</span>
129
- <span class='rbrace'>}</span></pre></dd>
130
-
131
- </dl>
132
-
133
-
134
-
135
-
136
-
137
- <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
138
- <ul class="summary">
139
-
140
- <li class="public ">
141
- <span class="summary_signature">
142
-
143
- <a href="#client-instance_method" title="#client (instance method)">- (Object) <strong>client</strong> </a>
144
-
145
-
146
-
147
- </span>
148
-
149
-
150
-
151
-
152
- <span class="note title readonly">readonly</span>
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
- <span class="summary_desc"><div class='inline'>
163
- <p>Returns the value of attribute client.</p>
164
- </div></span>
165
-
166
- </li>
167
-
168
-
169
- <li class="public ">
170
- <span class="summary_signature">
171
-
172
- <a href="#resource_mapping-instance_method" title="#resource_mapping (instance method)">- (Object) <strong>resource_mapping</strong> </a>
173
-
174
-
175
-
176
- </span>
177
-
178
-
179
-
180
-
181
- <span class="note title readonly">readonly</span>
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
- <span class="summary_desc"><div class='inline'>
192
- <p>Returns the value of attribute resource_mapping.</p>
193
- </div></span>
194
-
195
- </li>
196
-
197
-
198
- <li class="public ">
199
- <span class="summary_signature">
200
-
201
- <a href="#response-instance_method" title="#response (instance method)">- (Object) <strong>response</strong> </a>
202
-
203
-
204
-
205
- </span>
206
-
207
-
208
-
209
-
210
- <span class="note title readonly">readonly</span>
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
- <span class="summary_desc"><div class='inline'>
221
- <p>Returns the value of attribute response.</p>
222
- </div></span>
223
-
224
- </li>
225
-
226
-
227
- </ul>
228
-
229
-
230
-
231
-
232
-
233
- <h2>
234
- Instance Method Summary
235
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
236
- </h2>
237
-
238
- <ul class="summary">
239
-
240
- <li class="public ">
241
- <span class="summary_signature">
242
-
243
- <a href="#create_all_resources%21-instance_method" title="#create_all_resources! (instance method)">- (Object) <strong>create_all_resources!</strong> </a>
244
-
245
-
246
-
247
- </span>
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
- <span class="summary_desc"><div class='inline'>
258
- <p>PARSING MECHANISM - raise error if response not valid - look for included
259
- objects and parse them to resources - parse main object to resource -
260
- replace links in included resources with included resources - replace links
261
- in main resource with included resources - return main resource.</p>
262
- </div></span>
263
-
264
- </li>
265
-
266
-
267
- <li class="public ">
268
- <span class="summary_signature">
269
-
270
- <a href="#create_included_resources%21-instance_method" title="#create_included_resources! (instance method)">- (Object) <strong>create_included_resources!</strong>(included_objects) </a>
271
-
272
-
273
-
274
- </span>
275
-
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
- <span class="summary_desc"><div class='inline'></div></span>
285
-
286
- </li>
287
-
288
-
289
- <li class="public ">
290
- <span class="summary_signature">
291
-
292
- <a href="#create_resource-instance_method" title="#create_resource (instance method)">- (Object) <strong>create_resource</strong>(object) </a>
293
-
294
-
295
-
296
- </span>
297
-
298
-
299
-
300
-
301
-
302
-
303
-
304
-
305
-
306
- <span class="summary_desc"><div class='inline'></div></span>
307
-
308
- </li>
309
-
310
-
311
- <li class="public ">
312
- <span class="summary_signature">
313
-
314
- <a href="#default_resource_mapping-instance_method" title="#default_resource_mapping (instance method)">- (Object) <strong>default_resource_mapping</strong> </a>
315
-
316
-
317
-
318
- </span>
319
-
320
-
321
-
322
-
323
-
324
-
325
-
326
-
327
-
328
- <span class="summary_desc"><div class='inline'></div></span>
329
-
330
- </li>
331
-
332
-
333
- <li class="public ">
334
- <span class="summary_signature">
335
-
336
- <a href="#detect_child_objects-instance_method" title="#detect_child_objects (instance method)">- (Object) <strong>detect_child_objects</strong>(object) </a>
337
-
338
-
339
-
340
- </span>
341
-
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
- <span class="summary_desc"><div class='inline'></div></span>
351
-
352
- </li>
353
-
354
-
355
- <li class="public ">
356
- <span class="summary_signature">
357
-
358
- <a href="#detect_resource_class-instance_method" title="#detect_resource_class (instance method)">- (Object) <strong>detect_resource_class</strong>(object) </a>
359
-
360
-
361
-
362
- </span>
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
- <span class="summary_desc"><div class='inline'></div></span>
373
-
374
- </li>
375
-
376
-
377
- <li class="public ">
378
- <span class="summary_signature">
379
-
380
- <a href="#get_dynamic_entry-instance_method" title="#get_dynamic_entry (instance method)">- (Object) <strong>get_dynamic_entry</strong>(object) </a>
381
-
382
-
383
-
384
- </span>
385
-
386
-
387
-
388
-
389
-
390
-
391
-
392
-
393
-
394
- <span class="summary_desc"><div class='inline'></div></span>
395
-
396
- </li>
397
-
398
-
399
- <li class="public ">
400
- <span class="summary_signature">
401
-
402
- <a href="#initialize-instance_method" title="#initialize (instance method)">- (ResourceBuilder) <strong>initialize</strong>(client, response, resource_mapping = {}) </a>
403
-
404
-
405
-
406
- </span>
407
-
408
-
409
- <span class="note title constructor">constructor</span>
410
-
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
- <span class="summary_desc"><div class='inline'>
419
- <p>A new instance of ResourceBuilder.</p>
420
- </div></span>
421
-
422
- </li>
423
-
424
-
425
- <li class="public ">
426
- <span class="summary_signature">
427
-
428
- <a href="#maybe_replace_link-instance_method" title="#maybe_replace_link (instance method)">- (Object) <strong>maybe_replace_link</strong>(resource, parent, index) </a>
429
-
430
-
431
-
432
- </span>
433
-
434
-
435
-
436
-
437
-
438
-
439
-
440
-
441
-
442
- <span class="summary_desc"><div class='inline'></div></span>
443
-
444
- </li>
445
-
446
-
447
- <li class="public ">
448
- <span class="summary_signature">
449
-
450
- <a href="#replace_children-instance_method" title="#replace_children (instance method)">- (Object) <strong>replace_children</strong>(res, object) </a>
451
-
452
-
453
-
454
- </span>
455
-
456
-
457
-
458
-
459
-
460
-
461
-
462
-
463
-
464
- <span class="summary_desc"><div class='inline'></div></span>
465
-
466
- </li>
467
-
468
-
469
- <li class="public ">
470
- <span class="summary_signature">
471
-
472
- <a href="#replace_children_array-instance_method" title="#replace_children_array (instance method)">- (Object) <strong>replace_children_array</strong>(res, array_field) </a>
473
-
474
-
475
-
476
- </span>
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
- <span class="summary_desc"><div class='inline'></div></span>
487
-
488
- </li>
489
-
490
-
491
- <li class="public ">
492
- <span class="summary_signature">
493
-
494
- <a href="#replace_links_in_included_resources_with_included_resources-instance_method" title="#replace_links_in_included_resources_with_included_resources (instance method)">- (Object) <strong>replace_links_in_included_resources_with_included_resources</strong> </a>
495
-
496
-
497
-
498
- </span>
499
-
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
-
508
- <span class="summary_desc"><div class='inline'></div></span>
509
-
510
- </li>
511
-
512
-
513
- <li class="public ">
514
- <span class="summary_signature">
515
-
516
- <a href="#replace_links_with_included_resources-instance_method" title="#replace_links_with_included_resources (instance method)">- (Object) <strong>replace_links_with_included_resources</strong>(res) </a>
517
-
518
-
519
-
520
- </span>
521
-
522
-
523
-
524
-
525
-
526
-
527
-
528
-
529
-
530
- <span class="summary_desc"><div class='inline'></div></span>
531
-
532
- </li>
533
-
534
-
535
- <li class="public ">
536
- <span class="summary_signature">
537
-
538
- <a href="#run-instance_method" title="#run (instance method)">- (Object) <strong>run</strong> </a>
539
-
540
-
541
-
542
- </span>
543
-
544
-
545
-
546
-
547
-
548
-
549
-
550
-
551
-
552
- <span class="summary_desc"><div class='inline'></div></span>
553
-
554
- </li>
555
-
556
-
557
- <li class="public ">
558
- <span class="summary_signature">
559
-
560
- <a href="#try_dynamic_entry-instance_method" title="#try_dynamic_entry (instance method)">- (Object) <strong>try_dynamic_entry</strong>(object) </a>
561
-
562
-
563
-
564
- </span>
565
-
566
-
567
-
568
-
569
-
570
-
571
-
572
-
573
-
574
- <span class="summary_desc"><div class='inline'></div></span>
575
-
576
- </li>
577
-
578
-
579
- </ul>
580
-
581
-
582
- <div id="constructor_details" class="method_details_list">
583
- <h2>Constructor Details</h2>
584
-
585
- <div class="method_details first">
586
- <h3 class="signature first" id="initialize-instance_method">
587
-
588
- - (<tt><span class='object_link'><a href="" title="Contentful::ResourceBuilder (class)">ResourceBuilder</a></span></tt>) <strong>initialize</strong>(client, response, resource_mapping = {})
589
-
590
-
591
-
592
-
593
-
594
- </h3><div class="docstring">
595
- <div class="discussion">
596
-
597
- <p>Returns a new instance of ResourceBuilder</p>
598
-
599
-
600
- </div>
601
- </div>
602
- <div class="tags">
603
-
604
-
605
- </div><table class="source_code">
606
- <tr>
607
- <td>
608
- <pre class="lines">
609
-
610
-
611
- 26
612
- 27
613
- 28
614
- 29
615
- 30
616
- 31</pre>
617
- </td>
618
- <td>
619
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 26</span>
620
-
621
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_client'>client</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='comma'>,</span> <span class='id identifier rubyid_resource_mapping'>resource_mapping</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
622
- <span class='ivar'>@response</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span>
623
- <span class='ivar'>@client</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span>
624
- <span class='ivar'>@included_resources</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
625
- <span class='ivar'>@resource_mapping</span> <span class='op'>=</span> <span class='id identifier rubyid_default_resource_mapping'>default_resource_mapping</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_resource_mapping'>resource_mapping</span><span class='rparen'>)</span>
626
- <span class='kw'>end</span></pre>
627
- </td>
628
- </tr>
629
- </table>
630
- </div>
631
-
632
- </div>
633
-
634
- <div id="instance_attr_details" class="attr_details">
635
- <h2>Instance Attribute Details</h2>
636
-
637
-
638
- <span id=""></span>
639
- <div class="method_details first">
640
- <h3 class="signature first" id="client-instance_method">
641
-
642
- - (<tt>Object</tt>) <strong>client</strong> <span class="extras">(readonly)</span>
643
-
644
-
645
-
646
-
647
-
648
- </h3><div class="docstring">
649
- <div class="discussion">
650
-
651
- <p>Returns the value of attribute client</p>
652
-
653
-
654
- </div>
655
- </div>
656
- <div class="tags">
657
-
658
-
659
- </div><table class="source_code">
660
- <tr>
661
- <td>
662
- <pre class="lines">
663
-
664
-
665
- 23
666
- 24
667
- 25</pre>
668
- </td>
669
- <td>
670
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 23</span>
671
-
672
- <span class='kw'>def</span> <span class='id identifier rubyid_client'>client</span>
673
- <span class='ivar'>@client</span>
674
- <span class='kw'>end</span></pre>
675
- </td>
676
- </tr>
677
- </table>
678
- </div>
679
-
680
-
681
- <span id=""></span>
682
- <div class="method_details ">
683
- <h3 class="signature " id="resource_mapping-instance_method">
684
-
685
- - (<tt>Object</tt>) <strong>resource_mapping</strong> <span class="extras">(readonly)</span>
686
-
687
-
688
-
689
-
690
-
691
- </h3><div class="docstring">
692
- <div class="discussion">
693
-
694
- <p>Returns the value of attribute resource_mapping</p>
695
-
696
-
697
- </div>
698
- </div>
699
- <div class="tags">
700
-
701
-
702
- </div><table class="source_code">
703
- <tr>
704
- <td>
705
- <pre class="lines">
706
-
707
-
708
- 23
709
- 24
710
- 25</pre>
711
- </td>
712
- <td>
713
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 23</span>
714
-
715
- <span class='kw'>def</span> <span class='id identifier rubyid_resource_mapping'>resource_mapping</span>
716
- <span class='ivar'>@resource_mapping</span>
717
- <span class='kw'>end</span></pre>
718
- </td>
719
- </tr>
720
- </table>
721
- </div>
722
-
723
-
724
- <span id=""></span>
725
- <div class="method_details ">
726
- <h3 class="signature " id="response-instance_method">
727
-
728
- - (<tt>Object</tt>) <strong>response</strong> <span class="extras">(readonly)</span>
729
-
730
-
731
-
732
-
733
-
734
- </h3><div class="docstring">
735
- <div class="discussion">
736
-
737
- <p>Returns the value of attribute response</p>
738
-
739
-
740
- </div>
741
- </div>
742
- <div class="tags">
743
-
744
-
745
- </div><table class="source_code">
746
- <tr>
747
- <td>
748
- <pre class="lines">
749
-
750
-
751
- 23
752
- 24
753
- 25</pre>
754
- </td>
755
- <td>
756
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 23</span>
757
-
758
- <span class='kw'>def</span> <span class='id identifier rubyid_response'>response</span>
759
- <span class='ivar'>@response</span>
760
- <span class='kw'>end</span></pre>
761
- </td>
762
- </tr>
763
- </table>
764
- </div>
765
-
766
- </div>
767
-
768
-
769
- <div id="instance_method_details" class="method_details_list">
770
- <h2>Instance Method Details</h2>
771
-
772
-
773
- <div class="method_details first">
774
- <h3 class="signature first" id="create_all_resources!-instance_method">
775
-
776
- - (<tt>Object</tt>) <strong>create_all_resources!</strong>
777
-
778
-
779
-
780
-
781
-
782
- </h3><div class="docstring">
783
- <div class="discussion">
784
-
785
- <p>PARSING MECHANISM</p>
786
- <ul><li>
787
- <p>raise error if response not valid</p>
788
- </li><li>
789
- <p>look for included objects and parse them to resources</p>
790
- </li><li>
791
- <p>parse main object to resource</p>
792
- </li><li>
793
- <p>replace links in included resources with included resources</p>
794
- </li><li>
795
- <p>replace links in main resource with included resources</p>
796
- </li><li>
797
- <p>return main resource</p>
798
- </li></ul>
799
-
800
-
801
- </div>
802
- </div>
803
- <div class="tags">
804
-
805
-
806
- </div><table class="source_code">
807
- <tr>
808
- <td>
809
- <pre class="lines">
810
-
811
-
812
- 61
813
- 62
814
- 63
815
- 64
816
- 65
817
- 66
818
- 67
819
- 68
820
- 69</pre>
821
- </td>
822
- <td>
823
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 61</span>
824
-
825
- <span class='kw'>def</span> <span class='id identifier rubyid_create_all_resources!'>create_all_resources!</span>
826
- <span class='id identifier rubyid_create_included_resources!'>create_included_resources!</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>includes</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
827
- <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_create_resource'>create_resource</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
828
-
829
- <span class='id identifier rubyid_replace_links_in_included_resources_with_included_resources'>replace_links_in_included_resources_with_included_resources</span>
830
- <span class='id identifier rubyid_replace_links_with_included_resources'>replace_links_with_included_resources</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
831
-
832
- <span class='id identifier rubyid_res'>res</span>
833
- <span class='kw'>end</span></pre>
834
- </td>
835
- </tr>
836
- </table>
837
- </div>
838
-
839
- <div class="method_details ">
840
- <h3 class="signature " id="create_included_resources!-instance_method">
841
-
842
- - (<tt>Object</tt>) <strong>create_included_resources!</strong>(included_objects)
843
-
844
-
845
-
846
-
847
-
848
- </h3><table class="source_code">
849
- <tr>
850
- <td>
851
- <pre class="lines">
852
-
853
-
854
- 129
855
- 130
856
- 131
857
- 132
858
- 133
859
- 134
860
- 135
861
- 136
862
- 137
863
- 138
864
- 139
865
- 140</pre>
866
- </td>
867
- <td>
868
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 129</span>
869
-
870
- <span class='kw'>def</span> <span class='id identifier rubyid_create_included_resources!'>create_included_resources!</span><span class='lparen'>(</span><span class='id identifier rubyid_included_objects'>included_objects</span><span class='rparen'>)</span>
871
- <span class='kw'>if</span> <span class='id identifier rubyid_included_objects'>included_objects</span>
872
- <span class='id identifier rubyid_included_objects'>included_objects</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_objects'>objects</span><span class='op'>|</span>
873
- <span class='ivar'>@included_resources</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='lbracket'>[</span>
874
- <span class='id identifier rubyid_objects'>objects</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_object'>object</span><span class='op'>|</span>
875
- <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_create_resource'>create_resource</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
876
- <span class='lbracket'>[</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span> <span class='id identifier rubyid_res'>res</span><span class='rbracket'>]</span>
877
- <span class='rbrace'>}</span>
878
- <span class='rbracket'>]</span>
879
- <span class='rbrace'>}</span>
880
- <span class='kw'>end</span>
881
- <span class='kw'>end</span></pre>
882
- </td>
883
- </tr>
884
- </table>
885
- </div>
886
-
887
- <div class="method_details ">
888
- <h3 class="signature " id="create_resource-instance_method">
889
-
890
- - (<tt>Object</tt>) <strong>create_resource</strong>(object)
891
-
892
-
893
-
894
-
895
-
896
- </h3><table class="source_code">
897
- <tr>
898
- <td>
899
- <pre class="lines">
900
-
901
-
902
- 71
903
- 72
904
- 73
905
- 74
906
- 75
907
- 76
908
- 77</pre>
909
- </td>
910
- <td>
911
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 71</span>
912
-
913
- <span class='kw'>def</span> <span class='id identifier rubyid_create_resource'>create_resource</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
914
- <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_detect_resource_class'>detect_resource_class</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_client'>client</span><span class='rparen'>)</span>
915
- <span class='id identifier rubyid_replace_children'>replace_children</span> <span class='id identifier rubyid_res'>res</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span>
916
- <span class='id identifier rubyid_replace_children_array'>replace_children_array</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='comma'>,</span> <span class='symbol'>:items</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_array?'>array?</span>
917
-
918
- <span class='id identifier rubyid_res'>res</span>
919
- <span class='kw'>end</span></pre>
920
- </td>
921
- </tr>
922
- </table>
923
- </div>
924
-
925
- <div class="method_details ">
926
- <h3 class="signature " id="default_resource_mapping-instance_method">
927
-
928
- - (<tt>Object</tt>) <strong>default_resource_mapping</strong>
929
-
930
-
931
-
932
-
933
-
934
- </h3><table class="source_code">
935
- <tr>
936
- <td>
937
- <pre class="lines">
938
-
939
-
940
- 33
941
- 34
942
- 35</pre>
943
- </td>
944
- <td>
945
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 33</span>
946
-
947
- <span class='kw'>def</span> <span class='id identifier rubyid_default_resource_mapping'>default_resource_mapping</span>
948
- <span class='const'>DEFAULT_RESOURCE_MAPPING</span>
949
- <span class='kw'>end</span></pre>
950
- </td>
951
- </tr>
952
- </table>
953
- </div>
954
-
955
- <div class="method_details ">
956
- <h3 class="signature " id="detect_child_objects-instance_method">
957
-
958
- - (<tt>Object</tt>) <strong>detect_child_objects</strong>(object)
959
-
960
-
961
-
962
-
963
-
964
- </h3><table class="source_code">
965
- <tr>
966
- <td>
967
- <pre class="lines">
968
-
969
-
970
- 91
971
- 92
972
- 93
973
- 94
974
- 95
975
- 96
976
- 97</pre>
977
- </td>
978
- <td>
979
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 91</span>
980
-
981
- <span class='kw'>def</span> <span class='id identifier rubyid_detect_child_objects'>detect_child_objects</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
982
- <span class='kw'>if</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
983
- <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
984
- <span class='kw'>else</span>
985
- <span class='lbrace'>{</span><span class='rbrace'>}</span>
986
- <span class='kw'>end</span>
987
- <span class='kw'>end</span></pre>
988
- </td>
989
- </tr>
990
- </table>
991
- </div>
992
-
993
- <div class="method_details ">
994
- <h3 class="signature " id="detect_resource_class-instance_method">
995
-
996
- - (<tt>Object</tt>) <strong>detect_resource_class</strong>(object)
997
-
998
-
999
-
1000
-
1001
-
1002
- </h3><table class="source_code">
1003
- <tr>
1004
- <td>
1005
- <pre class="lines">
1006
-
1007
-
1008
- 79
1009
- 80
1010
- 81
1011
- 82
1012
- 83
1013
- 84
1014
- 85
1015
- 86
1016
- 87
1017
- 88
1018
- 89</pre>
1019
- </td>
1020
- <td>
1021
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 79</span>
1022
-
1023
- <span class='kw'>def</span> <span class='id identifier rubyid_detect_resource_class'>detect_resource_class</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1024
- <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>type</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
1025
- <span class='kw'>case</span> <span class='id identifier rubyid_res_class'>res_class</span> <span class='op'>=</span> <span class='id identifier rubyid_resource_mapping'>resource_mapping</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span>
1026
- <span class='kw'>when</span> <span class='const'>Symbol</span>
1027
- <span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_res_class'>res_class</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1028
- <span class='kw'>when</span> <span class='kw'>nil</span>
1029
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>UnsparsableResource</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
1030
- <span class='kw'>else</span>
1031
- <span class='id identifier rubyid_res_class'>res_class</span>
1032
- <span class='kw'>end</span>
1033
- <span class='kw'>end</span></pre>
1034
- </td>
1035
- </tr>
1036
- </table>
1037
- </div>
1038
-
1039
- <div class="method_details ">
1040
- <h3 class="signature " id="get_dynamic_entry-instance_method">
1041
-
1042
- - (<tt>Object</tt>) <strong>get_dynamic_entry</strong>(object)
1043
-
1044
-
1045
-
1046
-
1047
-
1048
- </h3><table class="source_code">
1049
- <tr>
1050
- <td>
1051
- <pre class="lines">
1052
-
1053
-
1054
- 120
1055
- 121
1056
- 122
1057
- 123
1058
- 124
1059
- 125
1060
- 126
1061
- 127</pre>
1062
- </td>
1063
- <td>
1064
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 120</span>
1065
-
1066
- <span class='kw'>def</span> <span class='id identifier rubyid_get_dynamic_entry'>get_dynamic_entry</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1067
- <span class='kw'>if</span> <span class='id identifier rubyid_id'>id</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span>
1068
- <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>contentType</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span>
1069
- <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>contentType</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span>
1070
- <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>contentType</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sys</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>id</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
1071
- <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_dynamic_entry_cache'>dynamic_entry_cache</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span>
1072
- <span class='kw'>end</span>
1073
- <span class='kw'>end</span></pre>
1074
- </td>
1075
- </tr>
1076
- </table>
1077
- </div>
1078
-
1079
- <div class="method_details ">
1080
- <h3 class="signature " id="maybe_replace_link-instance_method">
1081
-
1082
- - (<tt>Object</tt>) <strong>maybe_replace_link</strong>(resource, parent, index)
1083
-
1084
-
1085
-
1086
-
1087
-
1088
- </h3><table class="source_code">
1089
- <tr>
1090
- <td>
1091
- <pre class="lines">
1092
-
1093
-
1094
- 175
1095
- 176
1096
- 177
1097
- 178
1098
- 179
1099
- 180</pre>
1100
- </td>
1101
- <td>
1102
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 175</span>
1103
-
1104
- <span class='kw'>def</span> <span class='id identifier rubyid_maybe_replace_link'>maybe_replace_link</span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='rparen'>)</span>
1105
- <span class='kw'>if</span> <span class='ivar'>@included_resources</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_link_type'>link_type</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span>
1106
- <span class='ivar'>@included_resources</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_link_type'>link_type</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1107
- <span class='id identifier rubyid_parent'>parent</span><span class='lbracket'>[</span><span class='id identifier rubyid_index'>index</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@included_resources</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_link_type'>link_type</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span>
1108
- <span class='kw'>end</span>
1109
- <span class='kw'>end</span></pre>
1110
- </td>
1111
- </tr>
1112
- </table>
1113
- </div>
1114
-
1115
- <div class="method_details ">
1116
- <h3 class="signature " id="replace_children-instance_method">
1117
-
1118
- - (<tt>Object</tt>) <strong>replace_children</strong>(res, object)
1119
-
1120
-
1121
-
1122
-
1123
-
1124
- </h3><table class="source_code">
1125
- <tr>
1126
- <td>
1127
- <pre class="lines">
1128
-
1129
-
1130
- 99
1131
- 100
1132
- 101
1133
- 102
1134
- 103
1135
- 104
1136
- 105</pre>
1137
- </td>
1138
- <td>
1139
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 99</span>
1140
-
1141
- <span class='kw'>def</span> <span class='id identifier rubyid_replace_children'>replace_children</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1142
- <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_potential_objects'>potential_objects</span><span class='op'>|</span>
1143
- <span class='id identifier rubyid_detect_child_objects'>detect_child_objects</span><span class='lparen'>(</span><span class='id identifier rubyid_potential_objects'>potential_objects</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_child_name'>child_name</span><span class='comma'>,</span> <span class='id identifier rubyid_child_object'>child_object</span><span class='op'>|</span>
1144
- <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='id identifier rubyid_child_name'>child_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_create_resource'>create_resource</span><span class='lparen'>(</span><span class='id identifier rubyid_child_object'>child_object</span><span class='rparen'>)</span>
1145
- <span class='rbrace'>}</span>
1146
- <span class='rbrace'>}</span>
1147
- <span class='kw'>end</span></pre>
1148
- </td>
1149
- </tr>
1150
- </table>
1151
- </div>
1152
-
1153
- <div class="method_details ">
1154
- <h3 class="signature " id="replace_children_array-instance_method">
1155
-
1156
- - (<tt>Object</tt>) <strong>replace_children_array</strong>(res, array_field)
1157
-
1158
-
1159
-
1160
-
1161
-
1162
- </h3><table class="source_code">
1163
- <tr>
1164
- <td>
1165
- <pre class="lines">
1166
-
1167
-
1168
- 107
1169
- 108
1170
- 109
1171
- 110</pre>
1172
- </td>
1173
- <td>
1174
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 107</span>
1175
-
1176
- <span class='kw'>def</span> <span class='id identifier rubyid_replace_children_array'>replace_children_array</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='comma'>,</span> <span class='id identifier rubyid_array_field'>array_field</span><span class='rparen'>)</span>
1177
- <span class='id identifier rubyid_items'>items</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_array_field'>array_field</span><span class='rparen'>)</span>
1178
- <span class='id identifier rubyid_items'>items</span><span class='period'>.</span><span class='id identifier rubyid_map!'>map!</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_resource_object'>resource_object</span><span class='op'>|</span> <span class='id identifier rubyid_create_resource'>create_resource</span><span class='lparen'>(</span><span class='id identifier rubyid_resource_object'>resource_object</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1179
- <span class='kw'>end</span></pre>
1180
- </td>
1181
- </tr>
1182
- </table>
1183
- </div>
1184
-
1185
- <div class="method_details ">
1186
- <h3 class="signature " id="replace_links_in_included_resources_with_included_resources-instance_method">
1187
-
1188
- - (<tt>Object</tt>) <strong>replace_links_in_included_resources_with_included_resources</strong>
1189
-
1190
-
1191
-
1192
-
1193
-
1194
- </h3><table class="source_code">
1195
- <tr>
1196
- <td>
1197
- <pre class="lines">
1198
-
1199
-
1200
- 167
1201
- 168
1202
- 169
1203
- 170
1204
- 171
1205
- 172
1206
- 173</pre>
1207
- </td>
1208
- <td>
1209
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 167</span>
1210
-
1211
- <span class='kw'>def</span> <span class='id identifier rubyid_replace_links_in_included_resources_with_included_resources'>replace_links_in_included_resources_with_included_resources</span>
1212
- <span class='ivar'>@included_resources</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_for_type'>for_type</span><span class='op'>|</span>
1213
- <span class='id identifier rubyid_for_type'>for_type</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_res'>res</span><span class='op'>|</span>
1214
- <span class='id identifier rubyid_replace_links_with_included_resources'>replace_links_with_included_resources</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
1215
- <span class='rbrace'>}</span>
1216
- <span class='rbrace'>}</span>
1217
- <span class='kw'>end</span></pre>
1218
- </td>
1219
- </tr>
1220
- </table>
1221
- </div>
1222
-
1223
- <div class="method_details ">
1224
- <h3 class="signature " id="replace_links_with_included_resources-instance_method">
1225
-
1226
- - (<tt>Object</tt>) <strong>replace_links_with_included_resources</strong>(res)
1227
-
1228
-
1229
-
1230
-
1231
-
1232
- </h3><table class="source_code">
1233
- <tr>
1234
- <td>
1235
- <pre class="lines">
1236
-
1237
-
1238
- 142
1239
- 143
1240
- 144
1241
- 145
1242
- 146
1243
- 147
1244
- 148
1245
- 149
1246
- 150
1247
- 151
1248
- 152
1249
- 153
1250
- 154
1251
- 155
1252
- 156
1253
- 157
1254
- 158
1255
- 159
1256
- 160
1257
- 161
1258
- 162
1259
- 163
1260
- 164
1261
- 165</pre>
1262
- </td>
1263
- <td>
1264
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 142</span>
1265
-
1266
- <span class='kw'>def</span> <span class='id identifier rubyid_replace_links_with_included_resources'>replace_links_with_included_resources</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
1267
- <span class='kw'>unless</span> <span class='ivar'>@included_resources</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1268
- <span class='lbracket'>[</span><span class='symbol'>:properties</span><span class='comma'>,</span> <span class='symbol'>:sys</span><span class='comma'>,</span> <span class='symbol'>:fields</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__what'>_what</span><span class='op'>|</span>
1269
- <span class='kw'>if</span> <span class='id identifier rubyid_what'>what</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid__what'>_what</span><span class='rparen'>)</span>
1270
- <span class='id identifier rubyid_what'>what</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span><span class='op'>|</span>
1271
- <span class='kw'>if</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Link</span>
1272
- <span class='id identifier rubyid_maybe_replace_link'>maybe_replace_link</span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='id identifier rubyid_what'>what</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
1273
- <span class='kw'>elsif</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Resource</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_sys'>sys</span>
1274
- <span class='id identifier rubyid_replace_links_with_included_resources'>replace_links_with_included_resources</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
1275
- <span class='kw'>end</span>
1276
- <span class='rbrace'>}</span>
1277
- <span class='kw'>end</span>
1278
- <span class='rbrace'>}</span>
1279
- <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_array?'>array?</span>
1280
- <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='period'>.</span><span class='id identifier rubyid_with_index'>with_index</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span>
1281
- <span class='kw'>if</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Link</span>
1282
- <span class='id identifier rubyid_maybe_replace_link'>maybe_replace_link</span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_items'>items</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='rparen'>)</span>
1283
- <span class='kw'>else</span>
1284
- <span class='id identifier rubyid_replace_links_with_included_resources'>replace_links_with_included_resources</span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='rparen'>)</span>
1285
- <span class='kw'>end</span>
1286
- <span class='rbrace'>}</span>
1287
- <span class='kw'>end</span>
1288
- <span class='kw'>end</span>
1289
- <span class='kw'>end</span></pre>
1290
- </td>
1291
- </tr>
1292
- </table>
1293
- </div>
1294
-
1295
- <div class="method_details ">
1296
- <h3 class="signature " id="run-instance_method">
1297
-
1298
- - (<tt>Object</tt>) <strong>run</strong>
1299
-
1300
-
1301
-
1302
-
1303
-
1304
- </h3><table class="source_code">
1305
- <tr>
1306
- <td>
1307
- <pre class="lines">
1308
-
1309
-
1310
- 37
1311
- 38
1312
- 39
1313
- 40
1314
- 41
1315
- 42
1316
- 43
1317
- 44
1318
- 45
1319
- 46
1320
- 47
1321
- 48
1322
- 49
1323
- 50
1324
- 51
1325
- 52</pre>
1326
- </td>
1327
- <td>
1328
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 37</span>
1329
-
1330
- <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
1331
- <span class='kw'>case</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span>
1332
- <span class='kw'>when</span> <span class='symbol'>:contentful_error</span>
1333
- <span class='const'>Error</span><span class='lbracket'>[</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_raw'>raw</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
1334
- <span class='kw'>when</span> <span class='symbol'>:unparsable_json</span>
1335
- <span class='const'>UnparsableJson</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
1336
- <span class='kw'>when</span> <span class='symbol'>:not_contentful</span>
1337
- <span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
1338
- <span class='kw'>else</span>
1339
- <span class='kw'>begin</span>
1340
- <span class='id identifier rubyid_create_all_resources!'>create_all_resources!</span>
1341
- <span class='kw'>rescue</span> <span class='const'>UnparsableResource</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_error'>error</span>
1342
- <span class='id identifier rubyid_error'>error</span>
1343
- <span class='kw'>end</span>
1344
- <span class='kw'>end</span>
1345
- <span class='kw'>end</span></pre>
1346
- </td>
1347
- </tr>
1348
- </table>
1349
- </div>
1350
-
1351
- <div class="method_details ">
1352
- <h3 class="signature " id="try_dynamic_entry-instance_method">
1353
-
1354
- - (<tt>Object</tt>) <strong>try_dynamic_entry</strong>(object)
1355
-
1356
-
1357
-
1358
-
1359
-
1360
- </h3><table class="source_code">
1361
- <tr>
1362
- <td>
1363
- <pre class="lines">
1364
-
1365
-
1366
- 112
1367
- 113
1368
- 114
1369
- 115
1370
- 116
1371
- 117
1372
- 118</pre>
1373
- </td>
1374
- <td>
1375
- <pre class="code"><span class="info file"># File 'lib/contentful/resource_builder.rb', line 112</span>
1376
-
1377
- <span class='kw'>def</span> <span class='id identifier rubyid_try_dynamic_entry'>try_dynamic_entry</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1378
- <span class='kw'>if</span> <span class='ivar'>@client</span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='lbracket'>[</span><span class='symbol'>:dynamic_entries</span><span class='rbracket'>]</span>
1379
- <span class='id identifier rubyid_get_dynamic_entry'>get_dynamic_entry</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='const'>Entry</span>
1380
- <span class='kw'>else</span>
1381
- <span class='const'>Entry</span>
1382
- <span class='kw'>end</span>
1383
- <span class='kw'>end</span></pre>
1384
- </td>
1385
- </tr>
1386
- </table>
1387
- </div>
1388
-
1389
- </div>
1390
-
1391
- </div>
1392
-
1393
- <div id="footer">
1394
- Generated on Tue Mar 11 09:25:53 2014 by
1395
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1396
- 0.8.7.3 (ruby-1.9.3).
1397
- </div>
1398
-
1399
- </body>
1400
- </html>