ruby_odata 0.0.1 → 0.0.2
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.
- data/.gitignore +2 -1
- data/CHANGELOG.rdoc +10 -0
- data/VERSION +1 -1
- data/features/query_builder.feature +96 -0
- data/features/service.feature +0 -33
- data/features/step_definitions/service_steps.rb +35 -0
- data/lib/odata_ruby/query_builder.rb +15 -1
- data/ruby_odata.gemspec +6 -20
- metadata +7 -21
- data/doc/classes/OData.html +0 -126
- data/doc/classes/OData/ClassBuilder.html +0 -219
- data/doc/classes/OData/Operation.html +0 -194
- data/doc/classes/OData/QueryBuilder.html +0 -305
- data/doc/classes/OData/Service.html +0 -420
- data/doc/created.rid +0 -1
- data/doc/files/README_rdoc.html +0 -252
- data/doc/files/lib/odata_ruby/class_builder_rb.html +0 -101
- data/doc/files/lib/odata_ruby/operation_rb.html +0 -101
- data/doc/files/lib/odata_ruby/query_builder_rb.html +0 -101
- data/doc/files/lib/odata_ruby/service_rb.html +0 -101
- data/doc/files/lib/odata_ruby_rb.html +0 -114
- data/doc/fr_class_index.html +0 -31
- data/doc/fr_file_index.html +0 -32
- data/doc/fr_method_index.html +0 -40
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
@@ -1,420 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: OData::Service</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">OData::Service</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/odata_ruby/service_rb.html">
|
59
|
-
lib/odata_ruby/service.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div id="method-list">
|
86
|
-
<h3 class="section-bar">Methods</h3>
|
87
|
-
|
88
|
-
<div class="name-list">
|
89
|
-
<a href="#M000010">delete_object</a>
|
90
|
-
<a href="#M000013">execute</a>
|
91
|
-
<a href="#M000009">method_missing</a>
|
92
|
-
<a href="#M000008">new</a>
|
93
|
-
<a href="#M000014">respond_to?</a>
|
94
|
-
<a href="#M000012">save_changes</a>
|
95
|
-
<a href="#M000011">update_object</a>
|
96
|
-
</div>
|
97
|
-
</div>
|
98
|
-
|
99
|
-
</div>
|
100
|
-
|
101
|
-
|
102
|
-
<!-- if includes -->
|
103
|
-
|
104
|
-
<div id="section">
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<div id="attribute-list">
|
111
|
-
<h3 class="section-bar">Attributes</h3>
|
112
|
-
|
113
|
-
<div class="name-list">
|
114
|
-
<table>
|
115
|
-
<tr class="top-aligned-row context-row">
|
116
|
-
<td class="context-item-name">classes</td>
|
117
|
-
<td class="context-item-value"> [R] </td>
|
118
|
-
<td class="context-item-desc"></td>
|
119
|
-
</tr>
|
120
|
-
</table>
|
121
|
-
</div>
|
122
|
-
</div>
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
<!-- if method_list -->
|
127
|
-
<div id="methods">
|
128
|
-
<h3 class="section-bar">Public Class methods</h3>
|
129
|
-
|
130
|
-
<div id="method-M000008" class="method-detail">
|
131
|
-
<a name="M000008"></a>
|
132
|
-
|
133
|
-
<div class="method-heading">
|
134
|
-
<a href="#M000008" class="method-signature">
|
135
|
-
<span class="method-name">new</span><span class="method-args">(service_uri)</span>
|
136
|
-
</a>
|
137
|
-
</div>
|
138
|
-
|
139
|
-
<div class="method-description">
|
140
|
-
<p>
|
141
|
-
Creates a <a href="Service.html#M000008">new</a> instance of the <a
|
142
|
-
href="Service.html">Service</a> class
|
143
|
-
</p>
|
144
|
-
<h4>Required Attributes</h4>
|
145
|
-
<ul>
|
146
|
-
<li>service_uri: The root URI of the <a href="../OData.html">OData</a> service
|
147
|
-
|
148
|
-
</li>
|
149
|
-
</ul>
|
150
|
-
<p><a class="source-toggle" href="#"
|
151
|
-
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
152
|
-
<div class="method-source-code" id="M000008-source">
|
153
|
-
<pre>
|
154
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 9</span>
|
155
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">service_uri</span>)
|
156
|
-
<span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">service_uri</span>
|
157
|
-
<span class="ruby-ivar">@collections</span> = <span class="ruby-identifier">get_collections</span>
|
158
|
-
<span class="ruby-identifier">build_classes</span>
|
159
|
-
<span class="ruby-keyword kw">end</span>
|
160
|
-
</pre>
|
161
|
-
</div>
|
162
|
-
</div>
|
163
|
-
</div>
|
164
|
-
|
165
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
166
|
-
|
167
|
-
<div id="method-M000010" class="method-detail">
|
168
|
-
<a name="M000010"></a>
|
169
|
-
|
170
|
-
<div class="method-heading">
|
171
|
-
<a href="#M000010" class="method-signature">
|
172
|
-
<span class="method-name">delete_object</span><span class="method-args">(obj)</span>
|
173
|
-
</a>
|
174
|
-
</div>
|
175
|
-
|
176
|
-
<div class="method-description">
|
177
|
-
<p>
|
178
|
-
Queues an object for deletion. To actually remove it from the server, you
|
179
|
-
must call <a href="Service.html#M000012">save_changes</a> as well.
|
180
|
-
</p>
|
181
|
-
<h4>Required Attributes</h4>
|
182
|
-
<ul>
|
183
|
-
<li>obj: The object to mark for deletion
|
184
|
-
|
185
|
-
</li>
|
186
|
-
</ul>
|
187
|
-
<p>
|
188
|
-
Note: This method will throw an exception if the <tt>obj</tt> isn‘t a
|
189
|
-
tracked entity
|
190
|
-
</p>
|
191
|
-
<p><a class="source-toggle" href="#"
|
192
|
-
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
193
|
-
<div class="method-source-code" id="M000010-source">
|
194
|
-
<pre>
|
195
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 43</span>
|
196
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_object</span>(<span class="ruby-identifier">obj</span>)
|
197
|
-
<span class="ruby-identifier">type</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>
|
198
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:__metadata</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:__metadata</span>).<span class="ruby-identifier">nil?</span>
|
199
|
-
<span class="ruby-ivar">@save_operation</span> = <span class="ruby-constant">Operation</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"Delete"</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">obj</span>)
|
200
|
-
<span class="ruby-keyword kw">else</span>
|
201
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"You cannot delete a non-tracked entity"</span>
|
202
|
-
<span class="ruby-keyword kw">end</span>
|
203
|
-
<span class="ruby-keyword kw">end</span>
|
204
|
-
</pre>
|
205
|
-
</div>
|
206
|
-
</div>
|
207
|
-
</div>
|
208
|
-
|
209
|
-
<div id="method-M000013" class="method-detail">
|
210
|
-
<a name="M000013"></a>
|
211
|
-
|
212
|
-
<div class="method-heading">
|
213
|
-
<a href="#M000013" class="method-signature">
|
214
|
-
<span class="method-name">execute</span><span class="method-args">()</span>
|
215
|
-
</a>
|
216
|
-
</div>
|
217
|
-
|
218
|
-
<div class="method-description">
|
219
|
-
<p>
|
220
|
-
Performs query operations (Read) against the server
|
221
|
-
</p>
|
222
|
-
<p><a class="source-toggle" href="#"
|
223
|
-
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
224
|
-
<div class="method-source-code" id="M000013-source">
|
225
|
-
<pre>
|
226
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 94</span>
|
227
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>
|
228
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">get</span> <span class="ruby-identifier">build_query_uri</span>
|
229
|
-
<span class="ruby-identifier">build_classes_from_result</span>(<span class="ruby-identifier">result</span>)
|
230
|
-
<span class="ruby-keyword kw">end</span>
|
231
|
-
</pre>
|
232
|
-
</div>
|
233
|
-
</div>
|
234
|
-
</div>
|
235
|
-
|
236
|
-
<div id="method-M000009" class="method-detail">
|
237
|
-
<a name="M000009"></a>
|
238
|
-
|
239
|
-
<div class="method-heading">
|
240
|
-
<a href="#M000009" class="method-signature">
|
241
|
-
<span class="method-name">method_missing</span><span class="method-args">(name, *args)</span>
|
242
|
-
</a>
|
243
|
-
</div>
|
244
|
-
|
245
|
-
<div class="method-description">
|
246
|
-
<p>
|
247
|
-
Handles the dynamic AddTo<EntityName> methods as well as the
|
248
|
-
collections on the service
|
249
|
-
</p>
|
250
|
-
<p><a class="source-toggle" href="#"
|
251
|
-
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
252
|
-
<div class="method-source-code" id="M000009-source">
|
253
|
-
<pre>
|
254
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 16</span>
|
255
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
256
|
-
<span class="ruby-comment cmt"># Queries</span>
|
257
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@collections</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>)
|
258
|
-
<span class="ruby-identifier">root</span> = <span class="ruby-node">"/#{name.to_s.camelize}"</span>
|
259
|
-
<span class="ruby-identifier">root</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"(#{args.join(',')})"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
|
260
|
-
<span class="ruby-ivar">@query</span> = <span class="ruby-constant">QueryBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">root</span>)
|
261
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@query</span>
|
262
|
-
<span class="ruby-comment cmt"># Adds </span>
|
263
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^AddTo(.*)/</span>
|
264
|
-
<span class="ruby-identifier">type</span> = <span class="ruby-identifier">$1</span>
|
265
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@collections</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
|
266
|
-
<span class="ruby-ivar">@save_operation</span> = <span class="ruby-constant">Operation</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"Add"</span>, <span class="ruby-identifier">$1</span>, <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
|
267
|
-
<span class="ruby-keyword kw">else</span>
|
268
|
-
<span class="ruby-keyword kw">super</span>
|
269
|
-
<span class="ruby-keyword kw">end</span>
|
270
|
-
<span class="ruby-keyword kw">else</span>
|
271
|
-
<span class="ruby-keyword kw">super</span>
|
272
|
-
<span class="ruby-keyword kw">end</span>
|
273
|
-
|
274
|
-
<span class="ruby-keyword kw">end</span>
|
275
|
-
</pre>
|
276
|
-
</div>
|
277
|
-
</div>
|
278
|
-
</div>
|
279
|
-
|
280
|
-
<div id="method-M000014" class="method-detail">
|
281
|
-
<a name="M000014"></a>
|
282
|
-
|
283
|
-
<div class="method-heading">
|
284
|
-
<a href="#M000014" class="method-signature">
|
285
|
-
<span class="method-name">respond_to?</span><span class="method-args">(method)</span>
|
286
|
-
</a>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
<div class="method-description">
|
290
|
-
<p>
|
291
|
-
Overridden to identify methods handled by <a
|
292
|
-
href="Service.html#M000009">method_missing</a>
|
293
|
-
</p>
|
294
|
-
<p><a class="source-toggle" href="#"
|
295
|
-
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
296
|
-
<div class="method-source-code" id="M000014-source">
|
297
|
-
<pre>
|
298
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 100</span>
|
299
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">method</span>)
|
300
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@collections</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>)
|
301
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
302
|
-
<span class="ruby-comment cmt"># Adds </span>
|
303
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^AddTo(.*)/</span>
|
304
|
-
<span class="ruby-identifier">type</span> = <span class="ruby-identifier">$1</span>
|
305
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@collections</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
|
306
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
307
|
-
<span class="ruby-keyword kw">else</span>
|
308
|
-
<span class="ruby-keyword kw">super</span>
|
309
|
-
<span class="ruby-keyword kw">end</span>
|
310
|
-
<span class="ruby-keyword kw">else</span>
|
311
|
-
<span class="ruby-keyword kw">super</span>
|
312
|
-
<span class="ruby-keyword kw">end</span>
|
313
|
-
<span class="ruby-keyword kw">end</span>
|
314
|
-
</pre>
|
315
|
-
</div>
|
316
|
-
</div>
|
317
|
-
</div>
|
318
|
-
|
319
|
-
<div id="method-M000012" class="method-detail">
|
320
|
-
<a name="M000012"></a>
|
321
|
-
|
322
|
-
<div class="method-heading">
|
323
|
-
<a href="#M000012" class="method-signature">
|
324
|
-
<span class="method-name">save_changes</span><span class="method-args">()</span>
|
325
|
-
</a>
|
326
|
-
</div>
|
327
|
-
|
328
|
-
<div class="method-description">
|
329
|
-
<p>
|
330
|
-
Performs save operations (Create/Update/Delete) against the server
|
331
|
-
</p>
|
332
|
-
<p><a class="source-toggle" href="#"
|
333
|
-
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
334
|
-
<div class="method-source-code" id="M000012-source">
|
335
|
-
<pre>
|
336
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 68</span>
|
337
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_changes</span>
|
338
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">nil?</span>
|
339
|
-
|
340
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
|
341
|
-
|
342
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">kind</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"Add"</span>
|
343
|
-
<span class="ruby-identifier">save_uri</span> = <span class="ruby-node">"#{@uri}/#{@save_operation.klass_name}"</span>
|
344
|
-
<span class="ruby-identifier">json_klass</span> = <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_json</span>
|
345
|
-
<span class="ruby-identifier">post_result</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">post</span> <span class="ruby-identifier">save_uri</span>, <span class="ruby-identifier">json_klass</span>, <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:json</span>
|
346
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">build_classes_from_result</span>(<span class="ruby-identifier">post_result</span>)
|
347
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">kind</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"Update"</span>
|
348
|
-
<span class="ruby-identifier">update_uri</span> = <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:__metadata</span>)[<span class="ruby-identifier">:uri</span>]
|
349
|
-
<span class="ruby-identifier">json_klass</span> = <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_json</span>
|
350
|
-
<span class="ruby-identifier">update_result</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">put</span> <span class="ruby-identifier">update_uri</span>, <span class="ruby-identifier">json_klass</span>, <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:json</span>
|
351
|
-
<span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">update_result</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value">204</span>)
|
352
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">kind</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"Delete"</span>
|
353
|
-
<span class="ruby-identifier">delete_uri</span> = <span class="ruby-ivar">@save_operation</span>.<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:__metadata</span>)[<span class="ruby-identifier">:uri</span>]
|
354
|
-
<span class="ruby-identifier">delete_result</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">delete_uri</span>
|
355
|
-
<span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">delete_result</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value">204</span>)
|
356
|
-
<span class="ruby-keyword kw">end</span>
|
357
|
-
|
358
|
-
<span class="ruby-ivar">@save_operation</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># Clear out the last operation</span>
|
359
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
360
|
-
<span class="ruby-keyword kw">end</span>
|
361
|
-
</pre>
|
362
|
-
</div>
|
363
|
-
</div>
|
364
|
-
</div>
|
365
|
-
|
366
|
-
<div id="method-M000011" class="method-detail">
|
367
|
-
<a name="M000011"></a>
|
368
|
-
|
369
|
-
<div class="method-heading">
|
370
|
-
<a href="#M000011" class="method-signature">
|
371
|
-
<span class="method-name">update_object</span><span class="method-args">(obj)</span>
|
372
|
-
</a>
|
373
|
-
</div>
|
374
|
-
|
375
|
-
<div class="method-description">
|
376
|
-
<p>
|
377
|
-
Queues an object for update. To actually update it on the server, you must
|
378
|
-
call <a href="Service.html#M000012">save_changes</a> as well.
|
379
|
-
</p>
|
380
|
-
<h4>Required Attributes</h4>
|
381
|
-
<ul>
|
382
|
-
<li>obj: The object to queue for update
|
383
|
-
|
384
|
-
</li>
|
385
|
-
</ul>
|
386
|
-
<p>
|
387
|
-
Note: This method will throw an exception if the <tt>obj</tt> isn‘t a
|
388
|
-
tracked entity
|
389
|
-
</p>
|
390
|
-
<p><a class="source-toggle" href="#"
|
391
|
-
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
392
|
-
<div class="method-source-code" id="M000011-source">
|
393
|
-
<pre>
|
394
|
-
<span class="ruby-comment cmt"># File lib/odata_ruby/service.rb, line 58</span>
|
395
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_object</span>(<span class="ruby-identifier">obj</span>)
|
396
|
-
<span class="ruby-identifier">type</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>
|
397
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:__metadata</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:__metadata</span>).<span class="ruby-identifier">nil?</span>
|
398
|
-
<span class="ruby-ivar">@save_operation</span> = <span class="ruby-constant">Operation</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"Update"</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">obj</span>)
|
399
|
-
<span class="ruby-keyword kw">else</span>
|
400
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"You cannot update a non-tracked entity"</span>
|
401
|
-
<span class="ruby-keyword kw">end</span>
|
402
|
-
<span class="ruby-keyword kw">end</span>
|
403
|
-
</pre>
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
</div>
|
407
|
-
|
408
|
-
|
409
|
-
</div>
|
410
|
-
|
411
|
-
|
412
|
-
</div>
|
413
|
-
|
414
|
-
|
415
|
-
<div id="validator-badges">
|
416
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
417
|
-
</div>
|
418
|
-
|
419
|
-
</body>
|
420
|
-
</html>
|
data/doc/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Fri, 11 Jun 2010 18:01:50 -0400
|
data/doc/files/README_rdoc.html
DELETED
@@ -1,252 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: README.rdoc</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>README.rdoc</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>README.rdoc
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed Jun 09 22:59:40 -0400 2010</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<h1>odata_ruby</h1>
|
73
|
-
<p>
|
74
|
-
The <b>Open Data Protocol</b> (<a href="../classes/OData.html">OData</a>)
|
75
|
-
is a fantastic way to query and update data over standard Web technologies.
|
76
|
-
The odata_ruby library acts as a consumer of <a
|
77
|
-
href="../classes/OData.html">OData</a> services.
|
78
|
-
</p>
|
79
|
-
<h2>Usage</h2>
|
80
|
-
<p>
|
81
|
-
The API is a work in progress. Notably, changes can‘t be bundled
|
82
|
-
(through save_changes, only the last operation before save_changes is
|
83
|
-
persisted).
|
84
|
-
</p>
|
85
|
-
<h3>Adding</h3>
|
86
|
-
<p>
|
87
|
-
When you point at a service, an AddTo<EntityName> method is created
|
88
|
-
for you. This method takes in the new entity to create. To commit the
|
89
|
-
change, you need to call the save_changes method on the service. To add a
|
90
|
-
new category for example, you would simply do the following:
|
91
|
-
</p>
|
92
|
-
<pre>
|
93
|
-
require 'lib/odata_ruby'
|
94
|
-
|
95
|
-
svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc"
|
96
|
-
new_category = Category.new
|
97
|
-
new_category.Name = "Sample Category"
|
98
|
-
svc.AddToCategories(new_category)
|
99
|
-
category = svc.save_changes
|
100
|
-
puts category.to_json
|
101
|
-
</pre>
|
102
|
-
<h3>Updating</h3>
|
103
|
-
<p>
|
104
|
-
To update an object, simply pass the modified object to the update_object
|
105
|
-
method on the service. Updating, like adding requires you to call
|
106
|
-
save_changes in order to persist the change. For example:
|
107
|
-
</p>
|
108
|
-
<pre>
|
109
|
-
require 'lib/odata_ruby'
|
110
|
-
|
111
|
-
svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc"
|
112
|
-
new_category = Category.new
|
113
|
-
new_category.Name = "Sample Category"
|
114
|
-
svc.AddToCategories(new_category)
|
115
|
-
category = svc.save_changes
|
116
|
-
puts category.to_json
|
117
|
-
|
118
|
-
category.Name = 'Updated Category'
|
119
|
-
svc.update_object(category)
|
120
|
-
result = svc.save_changes
|
121
|
-
puts "Was the category updated? #{result}"
|
122
|
-
</pre>
|
123
|
-
<h3>Deleting</h3>
|
124
|
-
<p>
|
125
|
-
Deleting an object involves passing the tracked object to the delete_object
|
126
|
-
method on the service. Deleting is another function that involves the
|
127
|
-
save_changes method (to commit the change back to the server). In this
|
128
|
-
example, we‘ll add a category and then delete it.
|
129
|
-
</p>
|
130
|
-
<pre>
|
131
|
-
require 'lib/odata_ruby'
|
132
|
-
|
133
|
-
svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc"
|
134
|
-
new_category = Category.new
|
135
|
-
new_category.Name = "Sample Category"
|
136
|
-
svc.AddToCategories(new_category)
|
137
|
-
category = svc.save_changes
|
138
|
-
puts category.to_json
|
139
|
-
|
140
|
-
svc.delete_object(category)
|
141
|
-
result = svc.save_changes
|
142
|
-
puts "Was the category deleted? #{result}"
|
143
|
-
</pre>
|
144
|
-
<h3>Querying</h3>
|
145
|
-
<p>
|
146
|
-
Querying is easy, for example to pull all the categories from the
|
147
|
-
SampleService, you simply can run:
|
148
|
-
</p>
|
149
|
-
<pre>
|
150
|
-
require 'lib/odata_ruby'
|
151
|
-
|
152
|
-
svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc"
|
153
|
-
svc.Categories
|
154
|
-
categories = svc.execute
|
155
|
-
puts categories.to_json
|
156
|
-
</pre>
|
157
|
-
<p>
|
158
|
-
You can also expand and add filters to the query before executing it. For
|
159
|
-
example:
|
160
|
-
</p>
|
161
|
-
<h3>Expanding</h3>
|
162
|
-
<pre>
|
163
|
-
# Without expanding the query
|
164
|
-
svc.Products(1)
|
165
|
-
prod1 = svc.execute
|
166
|
-
puts "Without expanding the query"
|
167
|
-
puts "#{prod1.to_json}\n"
|
168
|
-
|
169
|
-
# With expanding the query
|
170
|
-
svc.Products(1).expand('Category')
|
171
|
-
prod1 = svc.execute
|
172
|
-
puts "Without expanding the query"
|
173
|
-
puts "#{prod1.to_json}\n"
|
174
|
-
</pre>
|
175
|
-
<h3>Filtering</h3>
|
176
|
-
<pre>
|
177
|
-
# You can access by ID (but that isn't is a filter)
|
178
|
-
# The syntax is just svc.ENTITYNAME(ID) which is shown in the expanding examples above
|
179
|
-
|
180
|
-
svc.Products.filter("Name eq 'Product 2'")
|
181
|
-
prod = svc.execute
|
182
|
-
puts "Filtering on Name eq 'Product 2'"
|
183
|
-
puts "#{prod.to_json}"
|
184
|
-
</pre>
|
185
|
-
<h3>Combining Expanding and Filtering</h3>
|
186
|
-
<pre>
|
187
|
-
svc.Products.filter("Name eq 'Product 2'").expand("Category")
|
188
|
-
prod = svc.execute
|
189
|
-
puts "Filtering on Name eq 'Product 2' and expanding"
|
190
|
-
puts "#{prod.to_json}"
|
191
|
-
</pre>
|
192
|
-
<h2>Tests</h2>
|
193
|
-
<p>
|
194
|
-
*DATABASE SETUP - DO THIS FIRST* Within /test/SampleService/App_Data/
|
195
|
-
rename _TestDB*.* to TestDB*.*. This file is just the inital database, and
|
196
|
-
needs to be renamed so that unwanted changes to that DB aren‘t
|
197
|
-
persisted in source control.
|
198
|
-
</p>
|
199
|
-
<p>
|
200
|
-
All of the tests are written using Cucumber going against a sample service
|
201
|
-
(Found in /test/SampleService/*). The SampleService is an ASP.NET Web Site
|
202
|
-
running a SQLEXPRESS 2008 R2 Database (TestDB), as well as the ADO.NET
|
203
|
-
Entity Framework and a WCF Data Service. In order to run the tests, you
|
204
|
-
need to spin up the SampleService and have it running on port 8888 (<a
|
205
|
-
href="http://localhost:8888/SampleService">localhost:8888/SampleService</a>).
|
206
|
-
</p>
|
207
|
-
<p>
|
208
|
-
One way to do this is to open the SampleService within Visual Studio 2010
|
209
|
-
and run it from there. Another option is to use Cassini (the built ASP.NET
|
210
|
-
Development server that comes with Visual Studio 2010). There is a batch
|
211
|
-
file found in /test called "Cassini x64.bat", you can run the
|
212
|
-
batch file and just close the command window. There is a also a
|
213
|
-
"Cassini x86.bat" file for those of you running a 32-bit machine,
|
214
|
-
however it hasn‘t been tested. The only difference is the path to the
|
215
|
-
Program Files directory. Once you run the batch file, the web server will
|
216
|
-
spin up and you can find the instance in your systray just like if Visual
|
217
|
-
Studio ran it for you. To stop the server, right click on the icon in your
|
218
|
-
systray and tell it to stop
|
219
|
-
</p>
|
220
|
-
|
221
|
-
</div>
|
222
|
-
|
223
|
-
|
224
|
-
</div>
|
225
|
-
|
226
|
-
|
227
|
-
</div>
|
228
|
-
|
229
|
-
|
230
|
-
<!-- if includes -->
|
231
|
-
|
232
|
-
<div id="section">
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
<!-- if method_list -->
|
242
|
-
|
243
|
-
|
244
|
-
</div>
|
245
|
-
|
246
|
-
|
247
|
-
<div id="validator-badges">
|
248
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
249
|
-
</div>
|
250
|
-
|
251
|
-
</body>
|
252
|
-
</html>
|