hyper-resource 1.0.0.lap79 → 1.0.0.lap80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.yardopts +1 -0
- data/API.md +62 -0
- data/Gemfile +2 -0
- data/JSON_format.md +62 -0
- data/PubSub.md +20 -0
- data/README.md +2 -0
- data/Security.md +0 -0
- data/docs/HyperRecord/ClassMethods.html +2969 -0
- data/docs/HyperRecord/ClientInstanceMethods.html +1833 -0
- data/docs/HyperRecord/Collection.html +564 -0
- data/docs/HyperRecord/DummyValue.html +384 -0
- data/docs/HyperRecord/PubSub/ClassMethods.html +2047 -0
- data/docs/HyperRecord/PubSub.html +1679 -0
- data/docs/HyperRecord/ServerClassMethods.html +697 -0
- data/docs/HyperRecord.html +119 -0
- data/docs/Hyperloop/Resource/ClientDrivers.html +352 -0
- data/docs/Hyperloop/Resource/HTTP.html +1795 -0
- data/docs/Hyperloop/Resource/MethodsController.html +479 -0
- data/docs/Hyperloop/Resource/PropertiesController.html +225 -0
- data/docs/Hyperloop/Resource/PubSub/ClassMethods.html +105 -0
- data/docs/Hyperloop/Resource/PubSub.html +1210 -0
- data/docs/Hyperloop/Resource/RelationsController.html +529 -0
- data/docs/Hyperloop/Resource/ScopesController.html +380 -0
- data/docs/Hyperloop/Resource/SecurityError.html +124 -0
- data/docs/Hyperloop/Resource/SecurityGuards/ClassMethods.html +226 -0
- data/docs/Hyperloop/Resource/SecurityGuards.html +299 -0
- data/docs/Hyperloop/Resource.html +135 -0
- data/docs/Hyperloop.html +186 -0
- data/docs/_index.html +302 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.API.html +138 -0
- data/docs/file.JSON_format.html +134 -0
- data/docs/file.PubSub.html +86 -0
- data/docs/file.README.html +192 -0
- data/docs/file_list.html +71 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +192 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1115 -0
- data/docs/top-level-namespace.html +110 -0
- data/hyper-resource.gemspec +19 -18
- data/lib/hyper_record/class_methods.rb +186 -3
- data/lib/hyper_record/client_instance_methods.rb +68 -3
- data/lib/hyper_record/collection.rb +19 -4
- data/lib/hyper_record/pub_sub.rb +92 -12
- data/lib/hyper_record/server_class_methods.rb +15 -0
- data/lib/hyperloop/resource/client_drivers.rb +2 -0
- data/lib/hyperloop/resource/http.rb +33 -22
- data/lib/hyperloop/resource/pub_sub.rb +2 -0
- data/lib/hyperloop/resource/version.rb +1 -1
- metadata +61 -2
@@ -0,0 +1,1795 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Hyperloop::Resource::HTTP
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.13
|
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
|
+
pathId = "Hyperloop::Resource::HTTP";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (H)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../Hyperloop.html" title="Hyperloop (module)">Hyperloop</a></span></span> » <span class='title'><span class='object_link'><a href="../Resource.html" title="Hyperloop::Resource (module)">Resource</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">HTTP</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Hyperloop::Resource::HTTP
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Hyperloop::Resource::HTTP</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/hyperloop/resource/http.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>HTTP is used to perform a `XMLHttpRequest` in ruby. It is a simple wrapper
|
106
|
+
around `XMLHttpRequest`</p>
|
107
|
+
|
108
|
+
<p># Making requests</p>
|
109
|
+
|
110
|
+
<p>To create a simple request, HTTP exposes class level methods to specify the
|
111
|
+
HTTP action you wish to perform. Each action accepts the url for the
|
112
|
+
request, as well as optional arguments passed as a hash:</p>
|
113
|
+
|
114
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="#get-class_method" title="Hyperloop::Resource::HTTP.get (method)">get</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/users/1.json</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
115
|
+
<span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_post'><span class='object_link'><a href="#post-class_method" title="Hyperloop::Resource::HTTP.post (method)">post</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
|
116
|
+
</code></pre>
|
117
|
+
|
118
|
+
<p>The supported `HTTP` actions are:</p>
|
119
|
+
<ul><li>
|
120
|
+
<p>HTTP.get</p>
|
121
|
+
</li><li>
|
122
|
+
<p>HTTP.post</p>
|
123
|
+
</li><li>
|
124
|
+
<p>HTTP.put</p>
|
125
|
+
</li><li>
|
126
|
+
<p>HTTP.delete</p>
|
127
|
+
</li><li>
|
128
|
+
<p>HTTP.patch</p>
|
129
|
+
</li><li>
|
130
|
+
<p>HTTP.head</p>
|
131
|
+
</li></ul>
|
132
|
+
|
133
|
+
<p># Handling responses</p>
|
134
|
+
|
135
|
+
<p>Responses can be handled using either a simple block callback, or using a
|
136
|
+
Promise returned by the request.</p>
|
137
|
+
|
138
|
+
<p>## Using a block</p>
|
139
|
+
|
140
|
+
<p>All HTTP action methods accept a block which can be used as a simple
|
141
|
+
handler for the request. The block will be called for both successful as
|
142
|
+
well as unsuccessful requests.</p>
|
143
|
+
|
144
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="#get-class_method" title="Hyperloop::Resource::HTTP.get (method)">get</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/users/1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_request'>request</span><span class='op'>|</span>
|
145
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>the request has completed!</span><span class='tstring_end'>"</span></span>
|
146
|
+
<span class='kw'>end</span>
|
147
|
+
</code></pre>
|
148
|
+
|
149
|
+
<p>This `request` object will simply be the instance of the HTTP class which
|
150
|
+
wraps the native `XMLHttpRequest`. HTTP#ok? can be used to quickly
|
151
|
+
determine if the request was successful.</p>
|
152
|
+
|
153
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="#get-class_method" title="Hyperloop::Resource::HTTP.get (method)">get</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/users/1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_request'>request</span><span class='op'>|</span>
|
154
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_ok?'>ok?</span>
|
155
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>request was success</span><span class='tstring_end'>"</span></span>
|
156
|
+
<span class='kw'>else</span>
|
157
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>something went wrong with request</span><span class='tstring_end'>"</span></span>
|
158
|
+
<span class='kw'>end</span>
|
159
|
+
<span class='kw'>end</span>
|
160
|
+
</code></pre>
|
161
|
+
|
162
|
+
<p>The HTTP instance will always be the only object passed to the block.</p>
|
163
|
+
|
164
|
+
<p>## Using a Promise</p>
|
165
|
+
|
166
|
+
<p>If no block is given to one of the action methods, then a Promise is
|
167
|
+
returned instead. See the standard library for more information on
|
168
|
+
Promises.</p>
|
169
|
+
|
170
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="#get-class_method" title="Hyperloop::Resource::HTTP.get (method)">get</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/users/1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_req'>req</span><span class='op'>|</span>
|
171
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>response ok!</span><span class='tstring_end'>"</span></span>
|
172
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_fail'>fail</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_req'>req</span><span class='op'>|</span>
|
173
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>response was not ok</span><span class='tstring_end'>"</span></span>
|
174
|
+
<span class='kw'>end</span>
|
175
|
+
</code></pre>
|
176
|
+
|
177
|
+
<p>When using a Promise, both success and failure handlers will be passed the
|
178
|
+
HTTP instance.</p>
|
179
|
+
|
180
|
+
<p># Accessing Response Data</p>
|
181
|
+
|
182
|
+
<p>All data returned from an HTTP request can be accessed via the HTTP object
|
183
|
+
passed into the block or promise handlers.</p>
|
184
|
+
<ul><li>
|
185
|
+
<p>#ok? - returns `true` or `false`, if request was a success (or not).</p>
|
186
|
+
</li><li>
|
187
|
+
<p>#body - returns the raw text response of the request</p>
|
188
|
+
</li><li>
|
189
|
+
<p>#status_code - returns the raw <span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span> status code as integer</p>
|
190
|
+
</li><li>
|
191
|
+
<p>#json - tries to convert the body response into a JSON object</p>
|
192
|
+
</li></ul>
|
193
|
+
|
194
|
+
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
<div class="tags">
|
198
|
+
|
199
|
+
|
200
|
+
</div>
|
201
|
+
|
202
|
+
<h2>
|
203
|
+
Constant Summary
|
204
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
205
|
+
</h2>
|
206
|
+
|
207
|
+
<dl class="constants">
|
208
|
+
|
209
|
+
<dt id="ACTIONS-constant" class="">ACTIONS =
|
210
|
+
<div class="docstring">
|
211
|
+
<div class="discussion">
|
212
|
+
|
213
|
+
<p>All valid HTTP action methods this class accepts.</p>
|
214
|
+
|
215
|
+
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
<div class="tags">
|
219
|
+
|
220
|
+
|
221
|
+
<p class="tag_title">See Also:</p>
|
222
|
+
<ul class="see">
|
223
|
+
|
224
|
+
<li><span class='object_link'><a href="#get-class_method" title="Hyperloop::Resource::HTTP.get (method)">get</a></span></li>
|
225
|
+
|
226
|
+
<li><span class='object_link'><a href="#post-class_method" title="Hyperloop::Resource::HTTP.post (method)">post</a></span></li>
|
227
|
+
|
228
|
+
<li><span class='object_link'><a href="#put-class_method" title="Hyperloop::Resource::HTTP.put (method)">put</a></span></li>
|
229
|
+
|
230
|
+
<li><span class='object_link'><a href="#delete-class_method" title="Hyperloop::Resource::HTTP.delete (method)">delete</a></span></li>
|
231
|
+
|
232
|
+
<li><span class='object_link'><a href="#patch-class_method" title="Hyperloop::Resource::HTTP.patch (method)">patch</a></span></li>
|
233
|
+
|
234
|
+
<li><span class='object_link'><a href="#head-class_method" title="Hyperloop::Resource::HTTP.head (method)">head</a></span></li>
|
235
|
+
|
236
|
+
</ul>
|
237
|
+
|
238
|
+
</div>
|
239
|
+
</dt>
|
240
|
+
<dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>get</span><span class='words_sep'> </span><span class='tstring_content'>post</span><span class='words_sep'> </span><span class='tstring_content'>put</span><span class='words_sep'> </span><span class='tstring_content'>delete</span><span class='words_sep'> </span><span class='tstring_content'>patch</span><span class='words_sep'> </span><span class='tstring_content'>head</span><span class='tstring_end'>]</span></span></pre></dd>
|
241
|
+
|
242
|
+
</dl>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
249
|
+
<ul class="summary">
|
250
|
+
|
251
|
+
<li class="public ">
|
252
|
+
<span class="summary_signature">
|
253
|
+
|
254
|
+
<a href="#body-instance_method" title="#body (instance method)">#<strong>body</strong> ⇒ Object </a>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
</span>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<span class="note title readonly">readonly</span>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
<span class="summary_desc"><div class='inline'>
|
274
|
+
<p>Returns the value of attribute body.</p>
|
275
|
+
</div></span>
|
276
|
+
|
277
|
+
</li>
|
278
|
+
|
279
|
+
|
280
|
+
<li class="public ">
|
281
|
+
<span class="summary_signature">
|
282
|
+
|
283
|
+
<a href="#error_message-instance_method" title="#error_message (instance method)">#<strong>error_message</strong> ⇒ Object </a>
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
</span>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
<span class="note title readonly">readonly</span>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
<span class="summary_desc"><div class='inline'>
|
303
|
+
<p>Returns the value of attribute error_message.</p>
|
304
|
+
</div></span>
|
305
|
+
|
306
|
+
</li>
|
307
|
+
|
308
|
+
|
309
|
+
<li class="public ">
|
310
|
+
<span class="summary_signature">
|
311
|
+
|
312
|
+
<a href="#method-instance_method" title="#method (instance method)">#<strong>method</strong> ⇒ Object </a>
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
</span>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<span class="note title readonly">readonly</span>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<span class="summary_desc"><div class='inline'>
|
332
|
+
<p>Returns the value of attribute method.</p>
|
333
|
+
</div></span>
|
334
|
+
|
335
|
+
</li>
|
336
|
+
|
337
|
+
|
338
|
+
<li class="public ">
|
339
|
+
<span class="summary_signature">
|
340
|
+
|
341
|
+
<a href="#status_code-instance_method" title="#status_code (instance method)">#<strong>status_code</strong> ⇒ Object </a>
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
</span>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
<span class="note title readonly">readonly</span>
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
<span class="summary_desc"><div class='inline'>
|
361
|
+
<p>Returns the value of attribute status_code.</p>
|
362
|
+
</div></span>
|
363
|
+
|
364
|
+
</li>
|
365
|
+
|
366
|
+
|
367
|
+
<li class="public ">
|
368
|
+
<span class="summary_signature">
|
369
|
+
|
370
|
+
<a href="#url-instance_method" title="#url (instance method)">#<strong>url</strong> ⇒ Object </a>
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
</span>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<span class="note title readonly">readonly</span>
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
<span class="summary_desc"><div class='inline'>
|
390
|
+
<p>Returns the value of attribute url.</p>
|
391
|
+
</div></span>
|
392
|
+
|
393
|
+
</li>
|
394
|
+
|
395
|
+
|
396
|
+
<li class="public ">
|
397
|
+
<span class="summary_signature">
|
398
|
+
|
399
|
+
<a href="#xhr-instance_method" title="#xhr (instance method)">#<strong>xhr</strong> ⇒ Object </a>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
</span>
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
<span class="note title readonly">readonly</span>
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
<span class="summary_desc"><div class='inline'>
|
419
|
+
<p>Returns the value of attribute xhr.</p>
|
420
|
+
</div></span>
|
421
|
+
|
422
|
+
</li>
|
423
|
+
|
424
|
+
|
425
|
+
</ul>
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
<h2>
|
432
|
+
Class Method Summary
|
433
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
434
|
+
</h2>
|
435
|
+
|
436
|
+
<ul class="summary">
|
437
|
+
|
438
|
+
<li class="public ">
|
439
|
+
<span class="summary_signature">
|
440
|
+
|
441
|
+
<a href="#active%3F-class_method" title="active? (class method)">.<strong>active?</strong> ⇒ Boolean </a>
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
</span>
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
<span class="summary_desc"><div class='inline'>
|
456
|
+
<p>check if requests are still active return [Boolean].</p>
|
457
|
+
</div></span>
|
458
|
+
|
459
|
+
</li>
|
460
|
+
|
461
|
+
|
462
|
+
<li class="public ">
|
463
|
+
<span class="summary_signature">
|
464
|
+
|
465
|
+
<a href="#delete-class_method" title="delete (class method)">.<strong>delete</strong>(url, options = {}, &block) ⇒ Object </a>
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
</span>
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
480
|
+
|
481
|
+
</li>
|
482
|
+
|
483
|
+
|
484
|
+
<li class="public ">
|
485
|
+
<span class="summary_signature">
|
486
|
+
|
487
|
+
<a href="#get-class_method" title="get (class method)">.<strong>get</strong>(url, options = {}) {|self| ... } ⇒ Promise<sup>?</sup> </a>
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
</span>
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
<span class="summary_desc"><div class='inline'>
|
502
|
+
<p>Create a <span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span> `get` request.</p>
|
503
|
+
</div></span>
|
504
|
+
|
505
|
+
</li>
|
506
|
+
|
507
|
+
|
508
|
+
<li class="public ">
|
509
|
+
<span class="summary_signature">
|
510
|
+
|
511
|
+
<a href="#head-class_method" title="head (class method)">.<strong>head</strong>(url, options = {}, &block) ⇒ Object </a>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
</span>
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
526
|
+
|
527
|
+
</li>
|
528
|
+
|
529
|
+
|
530
|
+
<li class="public ">
|
531
|
+
<span class="summary_signature">
|
532
|
+
|
533
|
+
<a href="#patch-class_method" title="patch (class method)">.<strong>patch</strong>(url, options = {}, &block) ⇒ Object </a>
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
</span>
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
548
|
+
|
549
|
+
</li>
|
550
|
+
|
551
|
+
|
552
|
+
<li class="public ">
|
553
|
+
<span class="summary_signature">
|
554
|
+
|
555
|
+
<a href="#post-class_method" title="post (class method)">.<strong>post</strong>(url, options = {}) {|self| ... } ⇒ Promise<sup>?</sup> </a>
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
</span>
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
<span class="summary_desc"><div class='inline'>
|
570
|
+
<p>Create a <span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span> `post` request.</p>
|
571
|
+
</div></span>
|
572
|
+
|
573
|
+
</li>
|
574
|
+
|
575
|
+
|
576
|
+
<li class="public ">
|
577
|
+
<span class="summary_signature">
|
578
|
+
|
579
|
+
<a href="#put-class_method" title="put (class method)">.<strong>put</strong>(url, options = {}, &block) ⇒ Object </a>
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
</span>
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
594
|
+
|
595
|
+
</li>
|
596
|
+
|
597
|
+
|
598
|
+
</ul>
|
599
|
+
|
600
|
+
<h2>
|
601
|
+
Instance Method Summary
|
602
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
603
|
+
</h2>
|
604
|
+
|
605
|
+
<ul class="summary">
|
606
|
+
|
607
|
+
<li class="public ">
|
608
|
+
<span class="summary_signature">
|
609
|
+
|
610
|
+
<a href="#get_header-instance_method" title="#get_header (instance method)">#<strong>get_header</strong>(key) ⇒ String<sup>?</sup> </a>
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
</span>
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
<span class="summary_desc"><div class='inline'>
|
625
|
+
<p>Returns the value of the specified response header.</p>
|
626
|
+
</div></span>
|
627
|
+
|
628
|
+
</li>
|
629
|
+
|
630
|
+
|
631
|
+
<li class="public ">
|
632
|
+
<span class="summary_signature">
|
633
|
+
|
634
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> ⇒ HTTP </a>
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
</span>
|
639
|
+
|
640
|
+
|
641
|
+
<span class="note title constructor">constructor</span>
|
642
|
+
|
643
|
+
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
<span class="summary_desc"><div class='inline'>
|
651
|
+
<p>A new instance of HTTP.</p>
|
652
|
+
</div></span>
|
653
|
+
|
654
|
+
</li>
|
655
|
+
|
656
|
+
|
657
|
+
<li class="public ">
|
658
|
+
<span class="summary_signature">
|
659
|
+
|
660
|
+
<a href="#inspect-instance_method" title="#inspect (instance method)">#<strong>inspect</strong> ⇒ String </a>
|
661
|
+
|
662
|
+
|
663
|
+
|
664
|
+
</span>
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
<span class="summary_desc"><div class='inline'>
|
675
|
+
<p>inspect on request.</p>
|
676
|
+
</div></span>
|
677
|
+
|
678
|
+
</li>
|
679
|
+
|
680
|
+
|
681
|
+
<li class="public ">
|
682
|
+
<span class="summary_signature">
|
683
|
+
|
684
|
+
<a href="#json-instance_method" title="#json (instance method)">#<strong>json</strong> ⇒ Hash, Array </a>
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
</span>
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
|
698
|
+
<span class="summary_desc"><div class='inline'>
|
699
|
+
<p>Parses the http response body through json.</p>
|
700
|
+
</div></span>
|
701
|
+
|
702
|
+
</li>
|
703
|
+
|
704
|
+
|
705
|
+
<li class="public ">
|
706
|
+
<span class="summary_signature">
|
707
|
+
|
708
|
+
<a href="#ok%3F-instance_method" title="#ok? (instance method)">#<strong>ok?</strong> ⇒ true, false </a>
|
709
|
+
|
710
|
+
|
711
|
+
|
712
|
+
</span>
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
|
721
|
+
|
722
|
+
<span class="summary_desc"><div class='inline'>
|
723
|
+
<p>Returns true if the request succeeded, false otherwise.</p>
|
724
|
+
</div></span>
|
725
|
+
|
726
|
+
</li>
|
727
|
+
|
728
|
+
|
729
|
+
</ul>
|
730
|
+
|
731
|
+
|
732
|
+
<div id="constructor_details" class="method_details_list">
|
733
|
+
<h2>Constructor Details</h2>
|
734
|
+
|
735
|
+
<div class="method_details first">
|
736
|
+
<h3 class="signature first" id="initialize-instance_method">
|
737
|
+
|
738
|
+
#<strong>initialize</strong> ⇒ <tt><span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span></tt>
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
|
743
|
+
|
744
|
+
</h3><div class="docstring">
|
745
|
+
<div class="discussion">
|
746
|
+
|
747
|
+
<p>Returns a new instance of HTTP</p>
|
748
|
+
|
749
|
+
|
750
|
+
</div>
|
751
|
+
</div>
|
752
|
+
<div class="tags">
|
753
|
+
|
754
|
+
|
755
|
+
</div><table class="source_code">
|
756
|
+
<tr>
|
757
|
+
<td>
|
758
|
+
<pre class="lines">
|
759
|
+
|
760
|
+
|
761
|
+
137
|
762
|
+
138
|
763
|
+
139</pre>
|
764
|
+
</td>
|
765
|
+
<td>
|
766
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 137</span>
|
767
|
+
|
768
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
769
|
+
<span class='ivar'>@ok</span> <span class='op'>=</span> <span class='kw'>true</span>
|
770
|
+
<span class='kw'>end</span></pre>
|
771
|
+
</td>
|
772
|
+
</tr>
|
773
|
+
</table>
|
774
|
+
</div>
|
775
|
+
|
776
|
+
</div>
|
777
|
+
|
778
|
+
<div id="instance_attr_details" class="attr_details">
|
779
|
+
<h2>Instance Attribute Details</h2>
|
780
|
+
|
781
|
+
|
782
|
+
<span id=""></span>
|
783
|
+
<div class="method_details first">
|
784
|
+
<h3 class="signature first" id="body-instance_method">
|
785
|
+
|
786
|
+
#<strong>body</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
</h3><div class="docstring">
|
793
|
+
<div class="discussion">
|
794
|
+
|
795
|
+
<p>Returns the value of attribute body</p>
|
796
|
+
|
797
|
+
|
798
|
+
</div>
|
799
|
+
</div>
|
800
|
+
<div class="tags">
|
801
|
+
|
802
|
+
|
803
|
+
</div><table class="source_code">
|
804
|
+
<tr>
|
805
|
+
<td>
|
806
|
+
<pre class="lines">
|
807
|
+
|
808
|
+
|
809
|
+
135
|
810
|
+
136
|
811
|
+
137</pre>
|
812
|
+
</td>
|
813
|
+
<td>
|
814
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 135</span>
|
815
|
+
|
816
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_body'>body</span>
|
817
|
+
<span class='ivar'>@body</span>
|
818
|
+
<span class='kw'>end</span></pre>
|
819
|
+
</td>
|
820
|
+
</tr>
|
821
|
+
</table>
|
822
|
+
</div>
|
823
|
+
|
824
|
+
|
825
|
+
<span id=""></span>
|
826
|
+
<div class="method_details ">
|
827
|
+
<h3 class="signature " id="error_message-instance_method">
|
828
|
+
|
829
|
+
#<strong>error_message</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
830
|
+
|
831
|
+
|
832
|
+
|
833
|
+
|
834
|
+
|
835
|
+
</h3><div class="docstring">
|
836
|
+
<div class="discussion">
|
837
|
+
|
838
|
+
<p>Returns the value of attribute error_message</p>
|
839
|
+
|
840
|
+
|
841
|
+
</div>
|
842
|
+
</div>
|
843
|
+
<div class="tags">
|
844
|
+
|
845
|
+
|
846
|
+
</div><table class="source_code">
|
847
|
+
<tr>
|
848
|
+
<td>
|
849
|
+
<pre class="lines">
|
850
|
+
|
851
|
+
|
852
|
+
135
|
853
|
+
136
|
854
|
+
137</pre>
|
855
|
+
</td>
|
856
|
+
<td>
|
857
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 135</span>
|
858
|
+
|
859
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_error_message'>error_message</span>
|
860
|
+
<span class='ivar'>@error_message</span>
|
861
|
+
<span class='kw'>end</span></pre>
|
862
|
+
</td>
|
863
|
+
</tr>
|
864
|
+
</table>
|
865
|
+
</div>
|
866
|
+
|
867
|
+
|
868
|
+
<span id=""></span>
|
869
|
+
<div class="method_details ">
|
870
|
+
<h3 class="signature " id="method-instance_method">
|
871
|
+
|
872
|
+
#<strong>method</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
873
|
+
|
874
|
+
|
875
|
+
|
876
|
+
|
877
|
+
|
878
|
+
</h3><div class="docstring">
|
879
|
+
<div class="discussion">
|
880
|
+
|
881
|
+
<p>Returns the value of attribute method</p>
|
882
|
+
|
883
|
+
|
884
|
+
</div>
|
885
|
+
</div>
|
886
|
+
<div class="tags">
|
887
|
+
|
888
|
+
|
889
|
+
</div><table class="source_code">
|
890
|
+
<tr>
|
891
|
+
<td>
|
892
|
+
<pre class="lines">
|
893
|
+
|
894
|
+
|
895
|
+
135
|
896
|
+
136
|
897
|
+
137</pre>
|
898
|
+
</td>
|
899
|
+
<td>
|
900
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 135</span>
|
901
|
+
|
902
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_method'>method</span>
|
903
|
+
<span class='ivar'>@method</span>
|
904
|
+
<span class='kw'>end</span></pre>
|
905
|
+
</td>
|
906
|
+
</tr>
|
907
|
+
</table>
|
908
|
+
</div>
|
909
|
+
|
910
|
+
|
911
|
+
<span id=""></span>
|
912
|
+
<div class="method_details ">
|
913
|
+
<h3 class="signature " id="status_code-instance_method">
|
914
|
+
|
915
|
+
#<strong>status_code</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
916
|
+
|
917
|
+
|
918
|
+
|
919
|
+
|
920
|
+
|
921
|
+
</h3><div class="docstring">
|
922
|
+
<div class="discussion">
|
923
|
+
|
924
|
+
<p>Returns the value of attribute status_code</p>
|
925
|
+
|
926
|
+
|
927
|
+
</div>
|
928
|
+
</div>
|
929
|
+
<div class="tags">
|
930
|
+
|
931
|
+
|
932
|
+
</div><table class="source_code">
|
933
|
+
<tr>
|
934
|
+
<td>
|
935
|
+
<pre class="lines">
|
936
|
+
|
937
|
+
|
938
|
+
135
|
939
|
+
136
|
940
|
+
137</pre>
|
941
|
+
</td>
|
942
|
+
<td>
|
943
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 135</span>
|
944
|
+
|
945
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_status_code'>status_code</span>
|
946
|
+
<span class='ivar'>@status_code</span>
|
947
|
+
<span class='kw'>end</span></pre>
|
948
|
+
</td>
|
949
|
+
</tr>
|
950
|
+
</table>
|
951
|
+
</div>
|
952
|
+
|
953
|
+
|
954
|
+
<span id=""></span>
|
955
|
+
<div class="method_details ">
|
956
|
+
<h3 class="signature " id="url-instance_method">
|
957
|
+
|
958
|
+
#<strong>url</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
|
964
|
+
</h3><div class="docstring">
|
965
|
+
<div class="discussion">
|
966
|
+
|
967
|
+
<p>Returns the value of attribute url</p>
|
968
|
+
|
969
|
+
|
970
|
+
</div>
|
971
|
+
</div>
|
972
|
+
<div class="tags">
|
973
|
+
|
974
|
+
|
975
|
+
</div><table class="source_code">
|
976
|
+
<tr>
|
977
|
+
<td>
|
978
|
+
<pre class="lines">
|
979
|
+
|
980
|
+
|
981
|
+
135
|
982
|
+
136
|
983
|
+
137</pre>
|
984
|
+
</td>
|
985
|
+
<td>
|
986
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 135</span>
|
987
|
+
|
988
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_url'>url</span>
|
989
|
+
<span class='ivar'>@url</span>
|
990
|
+
<span class='kw'>end</span></pre>
|
991
|
+
</td>
|
992
|
+
</tr>
|
993
|
+
</table>
|
994
|
+
</div>
|
995
|
+
|
996
|
+
|
997
|
+
<span id=""></span>
|
998
|
+
<div class="method_details ">
|
999
|
+
<h3 class="signature " id="xhr-instance_method">
|
1000
|
+
|
1001
|
+
#<strong>xhr</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
1002
|
+
|
1003
|
+
|
1004
|
+
|
1005
|
+
|
1006
|
+
|
1007
|
+
</h3><div class="docstring">
|
1008
|
+
<div class="discussion">
|
1009
|
+
|
1010
|
+
<p>Returns the value of attribute xhr</p>
|
1011
|
+
|
1012
|
+
|
1013
|
+
</div>
|
1014
|
+
</div>
|
1015
|
+
<div class="tags">
|
1016
|
+
|
1017
|
+
|
1018
|
+
</div><table class="source_code">
|
1019
|
+
<tr>
|
1020
|
+
<td>
|
1021
|
+
<pre class="lines">
|
1022
|
+
|
1023
|
+
|
1024
|
+
135
|
1025
|
+
136
|
1026
|
+
137</pre>
|
1027
|
+
</td>
|
1028
|
+
<td>
|
1029
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 135</span>
|
1030
|
+
|
1031
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_xhr'>xhr</span>
|
1032
|
+
<span class='ivar'>@xhr</span>
|
1033
|
+
<span class='kw'>end</span></pre>
|
1034
|
+
</td>
|
1035
|
+
</tr>
|
1036
|
+
</table>
|
1037
|
+
</div>
|
1038
|
+
|
1039
|
+
</div>
|
1040
|
+
|
1041
|
+
|
1042
|
+
<div id="class_method_details" class="method_details_list">
|
1043
|
+
<h2>Class Method Details</h2>
|
1044
|
+
|
1045
|
+
|
1046
|
+
<div class="method_details first">
|
1047
|
+
<h3 class="signature first" id="active?-class_method">
|
1048
|
+
|
1049
|
+
.<strong>active?</strong> ⇒ <tt>Boolean</tt>
|
1050
|
+
|
1051
|
+
|
1052
|
+
|
1053
|
+
|
1054
|
+
|
1055
|
+
</h3><div class="docstring">
|
1056
|
+
<div class="discussion">
|
1057
|
+
|
1058
|
+
<p>check if requests are still active return [Boolean]</p>
|
1059
|
+
|
1060
|
+
|
1061
|
+
</div>
|
1062
|
+
</div>
|
1063
|
+
<div class="tags">
|
1064
|
+
|
1065
|
+
<p class="tag_title">Returns:</p>
|
1066
|
+
<ul class="return">
|
1067
|
+
|
1068
|
+
<li>
|
1069
|
+
|
1070
|
+
|
1071
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1072
|
+
|
1073
|
+
|
1074
|
+
|
1075
|
+
</li>
|
1076
|
+
|
1077
|
+
</ul>
|
1078
|
+
|
1079
|
+
</div><table class="source_code">
|
1080
|
+
<tr>
|
1081
|
+
<td>
|
1082
|
+
<pre class="lines">
|
1083
|
+
|
1084
|
+
|
1085
|
+
143
|
1086
|
+
144
|
1087
|
+
145
|
1088
|
+
146
|
1089
|
+
147
|
1090
|
+
148
|
1091
|
+
149
|
1092
|
+
150
|
1093
|
+
151</pre>
|
1094
|
+
</td>
|
1095
|
+
<td>
|
1096
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 143</span>
|
1097
|
+
|
1098
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_active?'>active?</span>
|
1099
|
+
<span class='id identifier rubyid_jquery_active_requests'>jquery_active_requests</span> <span class='op'>=</span> <span class='int'>0</span>
|
1100
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1101
|
+
if (typeof jQuery !== "undefined" && typeof jQuery.active !== "undefined" && jQuery.active !== null) {
|
1102
|
+
jquery_active_requests = jQuery.active;
|
1103
|
+
}
|
1104
|
+
</span><span class='tstring_end'>}</span></span>
|
1105
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_jquery_active_requests'>jquery_active_requests</span> <span class='op'>+</span> <span class='ivar'>@active_requests</span><span class='rparen'>)</span> <span class='op'>></span> <span class='int'>0</span>
|
1106
|
+
<span class='kw'>end</span></pre>
|
1107
|
+
</td>
|
1108
|
+
</tr>
|
1109
|
+
</table>
|
1110
|
+
</div>
|
1111
|
+
|
1112
|
+
<div class="method_details ">
|
1113
|
+
<h3 class="signature " id="delete-class_method">
|
1114
|
+
|
1115
|
+
.<strong>delete</strong>(url, options = {}, &block) ⇒ <tt>Object</tt>
|
1116
|
+
|
1117
|
+
|
1118
|
+
|
1119
|
+
|
1120
|
+
|
1121
|
+
</h3><table class="source_code">
|
1122
|
+
<tr>
|
1123
|
+
<td>
|
1124
|
+
<pre class="lines">
|
1125
|
+
|
1126
|
+
|
1127
|
+
</pre>
|
1128
|
+
</td>
|
1129
|
+
<td>
|
1130
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 119</span>
|
1131
|
+
|
1132
|
+
</pre>
|
1133
|
+
</td>
|
1134
|
+
</tr>
|
1135
|
+
</table>
|
1136
|
+
</div>
|
1137
|
+
|
1138
|
+
<div class="method_details ">
|
1139
|
+
<h3 class="signature " id="get-class_method">
|
1140
|
+
|
1141
|
+
.<strong>get</strong>(url, options = {}) {|self| ... } ⇒ <tt>Promise</tt><sup>?</sup>
|
1142
|
+
|
1143
|
+
|
1144
|
+
|
1145
|
+
|
1146
|
+
|
1147
|
+
</h3><div class="docstring">
|
1148
|
+
<div class="discussion">
|
1149
|
+
|
1150
|
+
<p>Create a <span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">Hyperloop::Resource::HTTP</a></span> `get` request.</p>
|
1151
|
+
|
1152
|
+
|
1153
|
+
</div>
|
1154
|
+
</div>
|
1155
|
+
<div class="tags">
|
1156
|
+
|
1157
|
+
<div class="examples">
|
1158
|
+
<p class="tag_title">Examples:</p>
|
1159
|
+
|
1160
|
+
|
1161
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span></span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/foo</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_req'>req</span><span class='op'>|</span>
|
1162
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>got data: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
1163
|
+
<span class='kw'>end</span></code></pre>
|
1164
|
+
|
1165
|
+
</div>
|
1166
|
+
<p class="tag_title">Parameters:</p>
|
1167
|
+
<ul class="param">
|
1168
|
+
|
1169
|
+
<li>
|
1170
|
+
|
1171
|
+
<span class='name'>url</span>
|
1172
|
+
|
1173
|
+
|
1174
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1175
|
+
|
1176
|
+
|
1177
|
+
|
1178
|
+
—
|
1179
|
+
<div class='inline'>
|
1180
|
+
<p>url for request</p>
|
1181
|
+
</div>
|
1182
|
+
|
1183
|
+
</li>
|
1184
|
+
|
1185
|
+
<li>
|
1186
|
+
|
1187
|
+
<span class='name'>options</span>
|
1188
|
+
|
1189
|
+
|
1190
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1191
|
+
|
1192
|
+
|
1193
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
1194
|
+
|
1195
|
+
|
1196
|
+
—
|
1197
|
+
<div class='inline'>
|
1198
|
+
<p>any request options</p>
|
1199
|
+
</div>
|
1200
|
+
|
1201
|
+
</li>
|
1202
|
+
|
1203
|
+
</ul>
|
1204
|
+
|
1205
|
+
<p class="tag_title">Yields:</p>
|
1206
|
+
<ul class="yield">
|
1207
|
+
|
1208
|
+
<li>
|
1209
|
+
|
1210
|
+
|
1211
|
+
<span class='type'>(<tt>self</tt>)</span>
|
1212
|
+
|
1213
|
+
|
1214
|
+
|
1215
|
+
—
|
1216
|
+
<div class='inline'>
|
1217
|
+
<p>optional block to handle response</p>
|
1218
|
+
</div>
|
1219
|
+
|
1220
|
+
</li>
|
1221
|
+
|
1222
|
+
</ul>
|
1223
|
+
<p class="tag_title">Returns:</p>
|
1224
|
+
<ul class="return">
|
1225
|
+
|
1226
|
+
<li>
|
1227
|
+
|
1228
|
+
|
1229
|
+
<span class='type'>(<tt>Promise</tt>, <tt>nil</tt>)</span>
|
1230
|
+
|
1231
|
+
|
1232
|
+
|
1233
|
+
—
|
1234
|
+
<div class='inline'>
|
1235
|
+
<p>optionally returns a promise</p>
|
1236
|
+
</div>
|
1237
|
+
|
1238
|
+
</li>
|
1239
|
+
|
1240
|
+
</ul>
|
1241
|
+
|
1242
|
+
</div><table class="source_code">
|
1243
|
+
<tr>
|
1244
|
+
<td>
|
1245
|
+
<pre class="lines">
|
1246
|
+
|
1247
|
+
|
1248
|
+
</pre>
|
1249
|
+
</td>
|
1250
|
+
<td>
|
1251
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 87</span>
|
1252
|
+
|
1253
|
+
</pre>
|
1254
|
+
</td>
|
1255
|
+
</tr>
|
1256
|
+
</table>
|
1257
|
+
</div>
|
1258
|
+
|
1259
|
+
<div class="method_details ">
|
1260
|
+
<h3 class="signature " id="head-class_method">
|
1261
|
+
|
1262
|
+
.<strong>head</strong>(url, options = {}, &block) ⇒ <tt>Object</tt>
|
1263
|
+
|
1264
|
+
|
1265
|
+
|
1266
|
+
|
1267
|
+
|
1268
|
+
</h3><table class="source_code">
|
1269
|
+
<tr>
|
1270
|
+
<td>
|
1271
|
+
<pre class="lines">
|
1272
|
+
|
1273
|
+
|
1274
|
+
125
|
1275
|
+
126
|
1276
|
+
127
|
1277
|
+
128
|
1278
|
+
129
|
1279
|
+
130
|
1280
|
+
131
|
1281
|
+
132
|
1282
|
+
133</pre>
|
1283
|
+
</td>
|
1284
|
+
<td>
|
1285
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 125</span>
|
1286
|
+
|
1287
|
+
<span class='const'><span class='object_link'><a href="#ACTIONS-constant" title="Hyperloop::Resource::HTTP::ACTIONS (constant)">ACTIONS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_action'>action</span><span class='op'>|</span>
|
1288
|
+
<span class='id identifier rubyid_define_singleton_method'>define_singleton_method</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
|
1289
|
+
<span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1290
|
+
<span class='kw'>end</span>
|
1291
|
+
|
1292
|
+
<span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
|
1293
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1294
|
+
<span class='kw'>end</span>
|
1295
|
+
<span class='kw'>end</span></pre>
|
1296
|
+
</td>
|
1297
|
+
</tr>
|
1298
|
+
</table>
|
1299
|
+
</div>
|
1300
|
+
|
1301
|
+
<div class="method_details ">
|
1302
|
+
<h3 class="signature " id="patch-class_method">
|
1303
|
+
|
1304
|
+
.<strong>patch</strong>(url, options = {}, &block) ⇒ <tt>Object</tt>
|
1305
|
+
|
1306
|
+
|
1307
|
+
|
1308
|
+
|
1309
|
+
|
1310
|
+
</h3><table class="source_code">
|
1311
|
+
<tr>
|
1312
|
+
<td>
|
1313
|
+
<pre class="lines">
|
1314
|
+
|
1315
|
+
|
1316
|
+
</pre>
|
1317
|
+
</td>
|
1318
|
+
<td>
|
1319
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 121</span>
|
1320
|
+
|
1321
|
+
</pre>
|
1322
|
+
</td>
|
1323
|
+
</tr>
|
1324
|
+
</table>
|
1325
|
+
</div>
|
1326
|
+
|
1327
|
+
<div class="method_details ">
|
1328
|
+
<h3 class="signature " id="post-class_method">
|
1329
|
+
|
1330
|
+
.<strong>post</strong>(url, options = {}) {|self| ... } ⇒ <tt>Promise</tt><sup>?</sup>
|
1331
|
+
|
1332
|
+
|
1333
|
+
|
1334
|
+
|
1335
|
+
|
1336
|
+
</h3><div class="docstring">
|
1337
|
+
<div class="discussion">
|
1338
|
+
|
1339
|
+
<p>Create a <span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">Hyperloop::Resource::HTTP</a></span> `post` request. Post data can be supplied using the
|
1340
|
+
`payload` options. Usually this will be a hash which will get serialized
|
1341
|
+
into a native javascript object.</p>
|
1342
|
+
|
1343
|
+
|
1344
|
+
</div>
|
1345
|
+
</div>
|
1346
|
+
<div class="tags">
|
1347
|
+
|
1348
|
+
<div class="examples">
|
1349
|
+
<p class="tag_title">Examples:</p>
|
1350
|
+
|
1351
|
+
|
1352
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span></span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/bar</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_req'>req</span><span class='op'>|</span>
|
1353
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>got response</span><span class='tstring_end'>"</span></span>
|
1354
|
+
<span class='kw'>end</span></code></pre>
|
1355
|
+
|
1356
|
+
</div>
|
1357
|
+
<p class="tag_title">Parameters:</p>
|
1358
|
+
<ul class="param">
|
1359
|
+
|
1360
|
+
<li>
|
1361
|
+
|
1362
|
+
<span class='name'>url</span>
|
1363
|
+
|
1364
|
+
|
1365
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1366
|
+
|
1367
|
+
|
1368
|
+
|
1369
|
+
—
|
1370
|
+
<div class='inline'>
|
1371
|
+
<p>url for request</p>
|
1372
|
+
</div>
|
1373
|
+
|
1374
|
+
</li>
|
1375
|
+
|
1376
|
+
<li>
|
1377
|
+
|
1378
|
+
<span class='name'>options</span>
|
1379
|
+
|
1380
|
+
|
1381
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1382
|
+
|
1383
|
+
|
1384
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
1385
|
+
|
1386
|
+
|
1387
|
+
—
|
1388
|
+
<div class='inline'>
|
1389
|
+
<p>optional request options</p>
|
1390
|
+
</div>
|
1391
|
+
|
1392
|
+
</li>
|
1393
|
+
|
1394
|
+
</ul>
|
1395
|
+
|
1396
|
+
<p class="tag_title">Yields:</p>
|
1397
|
+
<ul class="yield">
|
1398
|
+
|
1399
|
+
<li>
|
1400
|
+
|
1401
|
+
|
1402
|
+
<span class='type'>(<tt>self</tt>)</span>
|
1403
|
+
|
1404
|
+
|
1405
|
+
|
1406
|
+
—
|
1407
|
+
<div class='inline'>
|
1408
|
+
<p>optional block to yield for response</p>
|
1409
|
+
</div>
|
1410
|
+
|
1411
|
+
</li>
|
1412
|
+
|
1413
|
+
</ul>
|
1414
|
+
<p class="tag_title">Returns:</p>
|
1415
|
+
<ul class="return">
|
1416
|
+
|
1417
|
+
<li>
|
1418
|
+
|
1419
|
+
|
1420
|
+
<span class='type'>(<tt>Promise</tt>, <tt>nil</tt>)</span>
|
1421
|
+
|
1422
|
+
|
1423
|
+
|
1424
|
+
—
|
1425
|
+
<div class='inline'>
|
1426
|
+
<p>returns a Promise unless block given</p>
|
1427
|
+
</div>
|
1428
|
+
|
1429
|
+
</li>
|
1430
|
+
|
1431
|
+
</ul>
|
1432
|
+
|
1433
|
+
</div><table class="source_code">
|
1434
|
+
<tr>
|
1435
|
+
<td>
|
1436
|
+
<pre class="lines">
|
1437
|
+
|
1438
|
+
|
1439
|
+
</pre>
|
1440
|
+
</td>
|
1441
|
+
<td>
|
1442
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 101</span>
|
1443
|
+
|
1444
|
+
</pre>
|
1445
|
+
</td>
|
1446
|
+
</tr>
|
1447
|
+
</table>
|
1448
|
+
</div>
|
1449
|
+
|
1450
|
+
<div class="method_details ">
|
1451
|
+
<h3 class="signature " id="put-class_method">
|
1452
|
+
|
1453
|
+
.<strong>put</strong>(url, options = {}, &block) ⇒ <tt>Object</tt>
|
1454
|
+
|
1455
|
+
|
1456
|
+
|
1457
|
+
|
1458
|
+
|
1459
|
+
</h3><table class="source_code">
|
1460
|
+
<tr>
|
1461
|
+
<td>
|
1462
|
+
<pre class="lines">
|
1463
|
+
|
1464
|
+
|
1465
|
+
</pre>
|
1466
|
+
</td>
|
1467
|
+
<td>
|
1468
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 117</span>
|
1469
|
+
|
1470
|
+
</pre>
|
1471
|
+
</td>
|
1472
|
+
</tr>
|
1473
|
+
</table>
|
1474
|
+
</div>
|
1475
|
+
|
1476
|
+
</div>
|
1477
|
+
|
1478
|
+
<div id="instance_method_details" class="method_details_list">
|
1479
|
+
<h2>Instance Method Details</h2>
|
1480
|
+
|
1481
|
+
|
1482
|
+
<div class="method_details first">
|
1483
|
+
<h3 class="signature first" id="get_header-instance_method">
|
1484
|
+
|
1485
|
+
#<strong>get_header</strong>(key) ⇒ <tt>String</tt><sup>?</sup>
|
1486
|
+
|
1487
|
+
|
1488
|
+
|
1489
|
+
|
1490
|
+
|
1491
|
+
</h3><div class="docstring">
|
1492
|
+
<div class="discussion">
|
1493
|
+
|
1494
|
+
<p>Returns the value of the specified response header.</p>
|
1495
|
+
|
1496
|
+
|
1497
|
+
</div>
|
1498
|
+
</div>
|
1499
|
+
<div class="tags">
|
1500
|
+
<p class="tag_title">Parameters:</p>
|
1501
|
+
<ul class="param">
|
1502
|
+
|
1503
|
+
<li>
|
1504
|
+
|
1505
|
+
<span class='name'>key</span>
|
1506
|
+
|
1507
|
+
|
1508
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1509
|
+
|
1510
|
+
|
1511
|
+
|
1512
|
+
—
|
1513
|
+
<div class='inline'>
|
1514
|
+
<p>name of the header to get</p>
|
1515
|
+
</div>
|
1516
|
+
|
1517
|
+
</li>
|
1518
|
+
|
1519
|
+
</ul>
|
1520
|
+
|
1521
|
+
<p class="tag_title">Returns:</p>
|
1522
|
+
<ul class="return">
|
1523
|
+
|
1524
|
+
<li>
|
1525
|
+
|
1526
|
+
|
1527
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1528
|
+
|
1529
|
+
|
1530
|
+
|
1531
|
+
—
|
1532
|
+
<div class='inline'>
|
1533
|
+
<p>value of the header</p>
|
1534
|
+
</div>
|
1535
|
+
|
1536
|
+
</li>
|
1537
|
+
|
1538
|
+
<li>
|
1539
|
+
|
1540
|
+
|
1541
|
+
<span class='type'>(<tt>nil</tt>)</span>
|
1542
|
+
|
1543
|
+
|
1544
|
+
|
1545
|
+
—
|
1546
|
+
<div class='inline'>
|
1547
|
+
<p>if the header <code>key</code> was not in the response</p>
|
1548
|
+
</div>
|
1549
|
+
|
1550
|
+
</li>
|
1551
|
+
|
1552
|
+
</ul>
|
1553
|
+
|
1554
|
+
</div><table class="source_code">
|
1555
|
+
<tr>
|
1556
|
+
<td>
|
1557
|
+
<pre class="lines">
|
1558
|
+
|
1559
|
+
|
1560
|
+
268
|
1561
|
+
269
|
1562
|
+
270
|
1563
|
+
271
|
1564
|
+
272
|
1565
|
+
273</pre>
|
1566
|
+
</td>
|
1567
|
+
<td>
|
1568
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 268</span>
|
1569
|
+
|
1570
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_header'>get_header</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1571
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1572
|
+
var value = </span><span class='embvar'>#</span><span class='ivar'>@xhr</span><span class='tstring_content'>.getResponseHeader(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>);
|
1573
|
+
return (value === null) ? nil : value;
|
1574
|
+
</span><span class='tstring_end'>}</span></span>
|
1575
|
+
<span class='kw'>end</span></pre>
|
1576
|
+
</td>
|
1577
|
+
</tr>
|
1578
|
+
</table>
|
1579
|
+
</div>
|
1580
|
+
|
1581
|
+
<div class="method_details ">
|
1582
|
+
<h3 class="signature " id="inspect-instance_method">
|
1583
|
+
|
1584
|
+
#<strong>inspect</strong> ⇒ <tt>String</tt>
|
1585
|
+
|
1586
|
+
|
1587
|
+
|
1588
|
+
|
1589
|
+
|
1590
|
+
</h3><div class="docstring">
|
1591
|
+
<div class="discussion">
|
1592
|
+
|
1593
|
+
<p>inspect on request</p>
|
1594
|
+
|
1595
|
+
|
1596
|
+
</div>
|
1597
|
+
</div>
|
1598
|
+
<div class="tags">
|
1599
|
+
|
1600
|
+
<p class="tag_title">Returns:</p>
|
1601
|
+
<ul class="return">
|
1602
|
+
|
1603
|
+
<li>
|
1604
|
+
|
1605
|
+
|
1606
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1607
|
+
|
1608
|
+
|
1609
|
+
|
1610
|
+
</li>
|
1611
|
+
|
1612
|
+
</ul>
|
1613
|
+
|
1614
|
+
</div><table class="source_code">
|
1615
|
+
<tr>
|
1616
|
+
<td>
|
1617
|
+
<pre class="lines">
|
1618
|
+
|
1619
|
+
|
1620
|
+
277
|
1621
|
+
278
|
1622
|
+
279</pre>
|
1623
|
+
</td>
|
1624
|
+
<td>
|
1625
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 277</span>
|
1626
|
+
|
1627
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span>
|
1628
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>#<HTTP @url=</span><span class='embexpr_beg'>#{</span><span class='ivar'>@url</span><span class='embexpr_end'>}</span><span class='tstring_content'> @method=</span><span class='embexpr_beg'>#{</span><span class='ivar'>@method</span><span class='embexpr_end'>}</span><span class='tstring_content'>></span><span class='tstring_end'>"</span></span>
|
1629
|
+
<span class='kw'>end</span></pre>
|
1630
|
+
</td>
|
1631
|
+
</tr>
|
1632
|
+
</table>
|
1633
|
+
</div>
|
1634
|
+
|
1635
|
+
<div class="method_details ">
|
1636
|
+
<h3 class="signature " id="json-instance_method">
|
1637
|
+
|
1638
|
+
#<strong>json</strong> ⇒ <tt>Hash</tt>, <tt>Array</tt>
|
1639
|
+
|
1640
|
+
|
1641
|
+
|
1642
|
+
|
1643
|
+
|
1644
|
+
</h3><div class="docstring">
|
1645
|
+
<div class="discussion">
|
1646
|
+
|
1647
|
+
<p>Parses the http response body through json. If the response is not valid
|
1648
|
+
JSON then an error will very likely be thrown.</p>
|
1649
|
+
|
1650
|
+
|
1651
|
+
</div>
|
1652
|
+
</div>
|
1653
|
+
<div class="tags">
|
1654
|
+
|
1655
|
+
<div class="examples">
|
1656
|
+
<p class="tag_title">Examples:</p>
|
1657
|
+
|
1658
|
+
|
1659
|
+
<p class="example_title"><div class='inline'>
|
1660
|
+
<p>Getting JSON content</p>
|
1661
|
+
</div></p>
|
1662
|
+
|
1663
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Hyperloop::Resource::HTTP (class)">HTTP</a></span></span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="#get-class_method" title="Hyperloop::Resource::HTTP.get (method)">get</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>api.json</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_response'>response</span><span class='op'>|</span>
|
1664
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_json'>json</span>
|
1665
|
+
<span class='kw'>end</span>
|
1666
|
+
|
1667
|
+
<span class='comment'># => {"key" => 1, "bar" => 2, ... }</span></code></pre>
|
1668
|
+
|
1669
|
+
</div>
|
1670
|
+
|
1671
|
+
<p class="tag_title">Returns:</p>
|
1672
|
+
<ul class="return">
|
1673
|
+
|
1674
|
+
<li>
|
1675
|
+
|
1676
|
+
|
1677
|
+
<span class='type'>(<tt>Hash</tt>, <tt>Array</tt>)</span>
|
1678
|
+
|
1679
|
+
|
1680
|
+
|
1681
|
+
—
|
1682
|
+
<div class='inline'>
|
1683
|
+
<p>returns the parsed json</p>
|
1684
|
+
</div>
|
1685
|
+
|
1686
|
+
</li>
|
1687
|
+
|
1688
|
+
</ul>
|
1689
|
+
|
1690
|
+
</div><table class="source_code">
|
1691
|
+
<tr>
|
1692
|
+
<td>
|
1693
|
+
<pre class="lines">
|
1694
|
+
|
1695
|
+
|
1696
|
+
244
|
1697
|
+
245
|
1698
|
+
246</pre>
|
1699
|
+
</td>
|
1700
|
+
<td>
|
1701
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 244</span>
|
1702
|
+
|
1703
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_json'>json</span>
|
1704
|
+
<span class='ivar'>@json</span> <span class='op'>||=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='ivar'>@body</span><span class='rparen'>)</span>
|
1705
|
+
<span class='kw'>end</span></pre>
|
1706
|
+
</td>
|
1707
|
+
</tr>
|
1708
|
+
</table>
|
1709
|
+
</div>
|
1710
|
+
|
1711
|
+
<div class="method_details ">
|
1712
|
+
<h3 class="signature " id="ok?-instance_method">
|
1713
|
+
|
1714
|
+
#<strong>ok?</strong> ⇒ <tt>true</tt>, <tt>false</tt>
|
1715
|
+
|
1716
|
+
|
1717
|
+
|
1718
|
+
|
1719
|
+
|
1720
|
+
</h3><div class="docstring">
|
1721
|
+
<div class="discussion">
|
1722
|
+
|
1723
|
+
<p>Returns true if the request succeeded, false otherwise.</p>
|
1724
|
+
|
1725
|
+
|
1726
|
+
</div>
|
1727
|
+
</div>
|
1728
|
+
<div class="tags">
|
1729
|
+
|
1730
|
+
<div class="examples">
|
1731
|
+
<p class="tag_title">Examples:</p>
|
1732
|
+
|
1733
|
+
|
1734
|
+
<pre class="example code"><code>HTTP.get("/some/url") do |response|
|
1735
|
+
if response.ok?
|
1736
|
+
alert "Yay!"
|
1737
|
+
else
|
1738
|
+
alert "Aww :("
|
1739
|
+
end</code></pre>
|
1740
|
+
|
1741
|
+
</div>
|
1742
|
+
|
1743
|
+
<p class="tag_title">Returns:</p>
|
1744
|
+
<ul class="return">
|
1745
|
+
|
1746
|
+
<li>
|
1747
|
+
|
1748
|
+
|
1749
|
+
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
|
1750
|
+
|
1751
|
+
|
1752
|
+
|
1753
|
+
—
|
1754
|
+
<div class='inline'>
|
1755
|
+
<p>true if request was successful</p>
|
1756
|
+
</div>
|
1757
|
+
|
1758
|
+
</li>
|
1759
|
+
|
1760
|
+
</ul>
|
1761
|
+
|
1762
|
+
</div><table class="source_code">
|
1763
|
+
<tr>
|
1764
|
+
<td>
|
1765
|
+
<pre class="lines">
|
1766
|
+
|
1767
|
+
|
1768
|
+
259
|
1769
|
+
260
|
1770
|
+
261</pre>
|
1771
|
+
</td>
|
1772
|
+
<td>
|
1773
|
+
<pre class="code"><span class="info file"># File 'lib/hyperloop/resource/http.rb', line 259</span>
|
1774
|
+
|
1775
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ok?'>ok?</span>
|
1776
|
+
<span class='ivar'>@ok</span>
|
1777
|
+
<span class='kw'>end</span></pre>
|
1778
|
+
</td>
|
1779
|
+
</tr>
|
1780
|
+
</table>
|
1781
|
+
</div>
|
1782
|
+
|
1783
|
+
</div>
|
1784
|
+
|
1785
|
+
</div>
|
1786
|
+
|
1787
|
+
<div id="footer">
|
1788
|
+
Generated on Tue Jun 5 23:13:53 2018 by
|
1789
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1790
|
+
0.9.13 (ruby-2.5.1).
|
1791
|
+
</div>
|
1792
|
+
|
1793
|
+
</div>
|
1794
|
+
</body>
|
1795
|
+
</html>
|