blobject 0.3.3 → 0.3.7
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 +1 -0
- data/Gemfile.lock +1 -1
- data/README.markdown +67 -13
- data/{blob_defn.png → assets/blob_defn.png} +0 -0
- data/{blobject.png → assets/blobject.png} +0 -0
- data/doc/Blobject.html +1393 -0
- data/doc/_index.html +110 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +269 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +269 -0
- data/doc/js/app.js +208 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +172 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/blobject/version.rb +2 -2
- data/lib/blobject.rb +73 -61
- data/spec/blobject_spec.rb +50 -6
- metadata +28 -13
- data/README.md_ +0 -145
data/doc/Blobject.html
ADDED
@@ -0,0 +1,1393 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Blobject
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.1
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index (B)</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">Blobject</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: Blobject
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">Blobject</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/blobject.rb<span class="defines">,<br />
|
98
|
+
lib/blobject/version.rb</span>
|
99
|
+
</dd>
|
100
|
+
|
101
|
+
</dl>
|
102
|
+
<div class="clear"></div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
|
107
|
+
<p>Wraps a hash to provide arbitrarily nested, object-style attribute access</p>
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div class="tags">
|
113
|
+
|
114
|
+
|
115
|
+
</div>
|
116
|
+
<h2>Constant Summary</h2>
|
117
|
+
|
118
|
+
<dl class="constants">
|
119
|
+
|
120
|
+
<dt id="ProhibitedNames-constant" class="">ProhibitedNames =
|
121
|
+
<div class="docstring">
|
122
|
+
<div class="discussion">
|
123
|
+
|
124
|
+
<p>filter :to_ary else Blobject#to_ary returns a blobject which is not cool,
|
125
|
+
especially if you are puts.</p>
|
126
|
+
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
<div class="tags">
|
131
|
+
|
132
|
+
|
133
|
+
</div>
|
134
|
+
</dt>
|
135
|
+
<dd><pre class="code"><span class='lbracket'>[</span><span class='symbol'>:to_ary</span><span class='rbracket'>]</span></pre></dd>
|
136
|
+
|
137
|
+
<dt id="VERSION-constant" class="">VERSION =
|
138
|
+
|
139
|
+
</dt>
|
140
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.3.3</span><span class='tstring_end'>'</span></span></pre></dd>
|
141
|
+
|
142
|
+
</dl>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
<h2>
|
153
|
+
Class Method Summary
|
154
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
155
|
+
</h2>
|
156
|
+
|
157
|
+
<ul class="summary">
|
158
|
+
|
159
|
+
<li class="public ">
|
160
|
+
<span class="summary_signature">
|
161
|
+
|
162
|
+
<a href="#from_json-class_method" title="from_json (class method)">+ (Object) <strong>from_json</strong>(json) </a>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
</span>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
<span class="summary_desc"><div class='inline'>
|
177
|
+
<p>get a Blobject from a json string if the yaml string describes an array, an
|
178
|
+
array will be returned.</p>
|
179
|
+
</div></span>
|
180
|
+
|
181
|
+
</li>
|
182
|
+
|
183
|
+
|
184
|
+
<li class="public ">
|
185
|
+
<span class="summary_signature">
|
186
|
+
|
187
|
+
<a href="#from_yaml-class_method" title="from_yaml (class method)">+ (Object) <strong>from_yaml</strong>(yaml) </a>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</span>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<span class="summary_desc"><div class='inline'>
|
202
|
+
<p>get a Blobject from a yaml string if the yaml string describes an array, an
|
203
|
+
array will be returned.</p>
|
204
|
+
</div></span>
|
205
|
+
|
206
|
+
</li>
|
207
|
+
|
208
|
+
|
209
|
+
</ul>
|
210
|
+
|
211
|
+
<h2>
|
212
|
+
Instance Method Summary
|
213
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
214
|
+
</h2>
|
215
|
+
|
216
|
+
<ul class="summary">
|
217
|
+
|
218
|
+
<li class="public ">
|
219
|
+
<span class="summary_signature">
|
220
|
+
|
221
|
+
<a href="#%3D%3D-instance_method" title="#== (instance method)">- (Object) <strong>==</strong>(other) </a>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</span>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<span class="summary_desc"><div class='inline'>
|
236
|
+
<p>compares Blobjects to Blobjects or Hashes.</p>
|
237
|
+
</div></span>
|
238
|
+
|
239
|
+
</li>
|
240
|
+
|
241
|
+
|
242
|
+
<li class="public ">
|
243
|
+
<span class="summary_signature">
|
244
|
+
|
245
|
+
<a href="#%5B%5D-instance_method" title="#[] (instance method)">- (Object) <strong>[]</strong>(name) </a>
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
</span>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
<span class="summary_desc"><div class='inline'>
|
260
|
+
<p>hash-like access to the Blobject's attributes.</p>
|
261
|
+
</div></span>
|
262
|
+
|
263
|
+
</li>
|
264
|
+
|
265
|
+
|
266
|
+
<li class="public ">
|
267
|
+
<span class="summary_signature">
|
268
|
+
|
269
|
+
<a href="#%5B%5D%3D-instance_method" title="#[]= (instance method)">- (Object) <strong>[]=</strong>(name, value) </a>
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
</span>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
<span class="summary_desc"><div class='inline'>
|
284
|
+
<p>hash-like attribtue setter.</p>
|
285
|
+
</div></span>
|
286
|
+
|
287
|
+
</li>
|
288
|
+
|
289
|
+
|
290
|
+
<li class="public ">
|
291
|
+
<span class="summary_signature">
|
292
|
+
|
293
|
+
<a href="#as_json-instance_method" title="#as_json (instance method)">- (Object) <strong>as_json</strong>(*args) </a>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
</span>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
<span class="summary_desc"><div class='inline'>
|
308
|
+
<p>returns a hash which can be serialized as json.</p>
|
309
|
+
</div></span>
|
310
|
+
|
311
|
+
</li>
|
312
|
+
|
313
|
+
|
314
|
+
<li class="public ">
|
315
|
+
<span class="summary_signature">
|
316
|
+
|
317
|
+
<a href="#freeze-instance_method" title="#freeze (instance method)">- (Object) <strong>freeze</strong> </a>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
</span>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<span class="summary_desc"><div class='inline'>
|
332
|
+
<p>freeze a Blobject to prevent it being modified.</p>
|
333
|
+
</div></span>
|
334
|
+
|
335
|
+
</li>
|
336
|
+
|
337
|
+
|
338
|
+
<li class="public ">
|
339
|
+
<span class="summary_signature">
|
340
|
+
|
341
|
+
<a href="#hash-instance_method" title="#hash (instance method)">- (Object) <strong>hash</strong> </a>
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
</span>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
<span class="summary_desc"><div class='inline'>
|
356
|
+
<p>access the internal hash.</p>
|
357
|
+
</div></span>
|
358
|
+
|
359
|
+
</li>
|
360
|
+
|
361
|
+
|
362
|
+
<li class="public ">
|
363
|
+
<span class="summary_signature">
|
364
|
+
|
365
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Blobject) <strong>initialize</strong>(hash = {}) {|_self| ... }</a>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
</span>
|
370
|
+
|
371
|
+
|
372
|
+
<span class="note title constructor">constructor</span>
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
<span class="summary_desc"><div class='inline'>
|
382
|
+
<p>pass an optional hash of values to preload you can also pass a block, the
|
383
|
+
new Blobject will be yield.</p>
|
384
|
+
</div></span>
|
385
|
+
|
386
|
+
</li>
|
387
|
+
|
388
|
+
|
389
|
+
<li class="public ">
|
390
|
+
<span class="summary_signature">
|
391
|
+
|
392
|
+
<a href="#inspect-instance_method" title="#inspect (instance method)">- (Object) <strong>inspect</strong> </a>
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
</span>
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
<span class="summary_desc"><div class='inline'>
|
407
|
+
<p>delegates to the internal Hash.</p>
|
408
|
+
</div></span>
|
409
|
+
|
410
|
+
</li>
|
411
|
+
|
412
|
+
|
413
|
+
<li class="public ">
|
414
|
+
<span class="summary_signature">
|
415
|
+
|
416
|
+
<a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Object) <strong>method_missing</strong>(method, *params, &block) </a>
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
</span>
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
<span class="summary_desc"><div class='inline'>
|
431
|
+
<p>method_missing is only called the first time an attribute is used.</p>
|
432
|
+
</div></span>
|
433
|
+
|
434
|
+
</li>
|
435
|
+
|
436
|
+
|
437
|
+
<li class="public ">
|
438
|
+
<span class="summary_signature">
|
439
|
+
|
440
|
+
<a href="#respond_to%3F-instance_method" title="#respond_to? (instance method)">- (Boolean) <strong>respond_to?</strong>(method) </a>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
</span>
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
455
|
+
|
456
|
+
</li>
|
457
|
+
|
458
|
+
|
459
|
+
<li class="public ">
|
460
|
+
<span class="summary_signature">
|
461
|
+
|
462
|
+
<a href="#to_hash-instance_method" title="#to_hash (instance method)">- (Object) <strong>to_hash</strong> </a>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
</span>
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
<span class="summary_desc"><div class='inline'>
|
477
|
+
<p>creates a recursive copy of the internal hash.</p>
|
478
|
+
</div></span>
|
479
|
+
|
480
|
+
</li>
|
481
|
+
|
482
|
+
|
483
|
+
<li class="public ">
|
484
|
+
<span class="summary_signature">
|
485
|
+
|
486
|
+
<a href="#to_json-instance_method" title="#to_json (instance method)">- (Object) <strong>to_json</strong>(*args) </a>
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
</span>
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
<span class="summary_desc"><div class='inline'>
|
501
|
+
<p>serialize the Blobject as a json string.</p>
|
502
|
+
</div></span>
|
503
|
+
|
504
|
+
</li>
|
505
|
+
|
506
|
+
|
507
|
+
<li class="public ">
|
508
|
+
<span class="summary_signature">
|
509
|
+
|
510
|
+
<a href="#to_yaml-instance_method" title="#to_yaml (instance method)">- (Object) <strong>to_yaml</strong> </a>
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
</span>
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
<span class="summary_desc"><div class='inline'>
|
525
|
+
<p>serialize the Blobject as a yaml string.</p>
|
526
|
+
</div></span>
|
527
|
+
|
528
|
+
</li>
|
529
|
+
|
530
|
+
|
531
|
+
</ul>
|
532
|
+
|
533
|
+
|
534
|
+
<div id="constructor_details" class="method_details_list">
|
535
|
+
<h2>Constructor Details</h2>
|
536
|
+
|
537
|
+
<div class="method_details first">
|
538
|
+
<h3 class="signature first" id="initialize-instance_method">
|
539
|
+
|
540
|
+
- (<tt><span class='object_link'><a href="" title="Blobject (class)">Blobject</a></span></tt>) <strong>initialize</strong>(hash = {}) {|_self| ... }
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
</h3><div class="docstring">
|
547
|
+
<div class="discussion">
|
548
|
+
|
549
|
+
<p>pass an optional hash of values to preload you can also pass a block, the
|
550
|
+
new Blobject will be yield</p>
|
551
|
+
|
552
|
+
|
553
|
+
</div>
|
554
|
+
</div>
|
555
|
+
<div class="tags">
|
556
|
+
|
557
|
+
<p class="tag_title">Yields:</p>
|
558
|
+
<ul class="yield">
|
559
|
+
|
560
|
+
<li>
|
561
|
+
|
562
|
+
|
563
|
+
<span class='type'>(<tt>_self</tt>)</span>
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
</li>
|
568
|
+
|
569
|
+
</ul>
|
570
|
+
<p class="tag_title">Yield Parameters:</p>
|
571
|
+
<ul class="yieldparam">
|
572
|
+
|
573
|
+
<li>
|
574
|
+
|
575
|
+
<span class='name'>_self</span>
|
576
|
+
|
577
|
+
|
578
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Blobject (class)">Blobject</a></span></tt>)</span>
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
—
|
583
|
+
<div class='inline'>
|
584
|
+
<p>the object that the method was called on</p>
|
585
|
+
</div>
|
586
|
+
|
587
|
+
</li>
|
588
|
+
|
589
|
+
</ul>
|
590
|
+
|
591
|
+
</div><table class="source_code">
|
592
|
+
<tr>
|
593
|
+
<td>
|
594
|
+
<pre class="lines">
|
595
|
+
|
596
|
+
|
597
|
+
14
|
598
|
+
15
|
599
|
+
16
|
600
|
+
17
|
601
|
+
18
|
602
|
+
19
|
603
|
+
20
|
604
|
+
21
|
605
|
+
22
|
606
|
+
23
|
607
|
+
24
|
608
|
+
25
|
609
|
+
26
|
610
|
+
27
|
611
|
+
28
|
612
|
+
29
|
613
|
+
30
|
614
|
+
31
|
615
|
+
32
|
616
|
+
33</pre>
|
617
|
+
</td>
|
618
|
+
<td>
|
619
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 14</span>
|
620
|
+
|
621
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
622
|
+
|
623
|
+
<span class='ivar'>@hash</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
|
624
|
+
|
625
|
+
<span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</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_key'>key</span><span class='op'>|</span>
|
626
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'><=</span> <span class='const'>Symbol</span>
|
627
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_key'>key</span>
|
628
|
+
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
|
629
|
+
<span class='ivar'>@hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
630
|
+
<span class='kw'>end</span>
|
631
|
+
<span class='kw'>end</span>
|
632
|
+
|
633
|
+
<span class='id identifier rubyid___visit_subtree__'>__visit_subtree__</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
|
634
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'><=</span> <span class='const'>Hash</span>
|
635
|
+
<span class='ivar'>@hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Blobject</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_node'>node</span>
|
636
|
+
<span class='kw'>end</span>
|
637
|
+
<span class='kw'>end</span>
|
638
|
+
|
639
|
+
<span class='kw'>yield</span> <span class='kw'>self</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
640
|
+
<span class='kw'>end</span></pre>
|
641
|
+
</td>
|
642
|
+
</tr>
|
643
|
+
</table>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
</div>
|
647
|
+
<div id="method_missing_details" class="method_details_list">
|
648
|
+
<h2>Dynamic Method Handling</h2>
|
649
|
+
<p class="notice this">
|
650
|
+
This class handles dynamic methods through the <tt>method_missing</tt> method
|
651
|
+
|
652
|
+
</p>
|
653
|
+
|
654
|
+
<div class="method_details first">
|
655
|
+
<h3 class="signature first" id="method_missing-instance_method">
|
656
|
+
|
657
|
+
- (<tt>Object</tt>) <strong>method_missing</strong>(method, *params, &block)
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
|
662
|
+
|
663
|
+
</h3><div class="docstring">
|
664
|
+
<div class="discussion">
|
665
|
+
|
666
|
+
<p>method_missing is only called the first time an attribute is used.
|
667
|
+
successive calls use memoized getters, setters and checkers</p>
|
668
|
+
|
669
|
+
|
670
|
+
</div>
|
671
|
+
</div>
|
672
|
+
<div class="tags">
|
673
|
+
|
674
|
+
|
675
|
+
</div><table class="source_code">
|
676
|
+
<tr>
|
677
|
+
<td>
|
678
|
+
<pre class="lines">
|
679
|
+
|
680
|
+
|
681
|
+
59
|
682
|
+
60
|
683
|
+
61
|
684
|
+
62
|
685
|
+
63
|
686
|
+
64
|
687
|
+
65
|
688
|
+
66
|
689
|
+
67
|
690
|
+
68
|
691
|
+
69
|
692
|
+
70
|
693
|
+
71
|
694
|
+
72
|
695
|
+
73
|
696
|
+
74
|
697
|
+
75
|
698
|
+
76
|
699
|
+
77
|
700
|
+
78
|
701
|
+
79
|
702
|
+
80
|
703
|
+
81
|
704
|
+
82
|
705
|
+
83
|
706
|
+
84
|
707
|
+
85
|
708
|
+
86
|
709
|
+
87
|
710
|
+
88
|
711
|
+
89
|
712
|
+
90
|
713
|
+
91
|
714
|
+
92
|
715
|
+
93
|
716
|
+
94
|
717
|
+
95
|
718
|
+
96
|
719
|
+
97
|
720
|
+
98
|
721
|
+
99</pre>
|
722
|
+
</td>
|
723
|
+
<td>
|
724
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 59</span>
|
725
|
+
|
726
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span> <span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_params'>params</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
727
|
+
|
728
|
+
<span class='id identifier rubyid___tag_and_raise__'>__tag_and_raise__</span> <span class='const'>NoMethodError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='const'>ProhibitedNames</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
|
729
|
+
|
730
|
+
<span class='kw'>case</span>
|
731
|
+
<span class='comment'># assignment in conditionals is usually a bad smell, here it helps minimize regex matching
|
732
|
+
</span> <span class='kw'>when</span> <span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\w+$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>0</span>
|
733
|
+
<span class='comment'># the call is an attribute reader
|
734
|
+
</span> <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_frozen?'>frozen?</span> <span class='kw'>and</span> <span class='kw'>not</span> <span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
|
735
|
+
|
736
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='symbol'>:__define_attribute__</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span>
|
737
|
+
|
738
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span> <span class='id identifier rubyid_method'>method</span>
|
739
|
+
|
740
|
+
<span class='id identifier rubyid_parent'>parent</span> <span class='op'>=</span> <span class='kw'>self</span>
|
741
|
+
<span class='id identifier rubyid_nested_blobject'>nested_blobject</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
742
|
+
|
743
|
+
<span class='id identifier rubyid_store_in_parent'>store_in_parent</span> <span class='op'>=</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='kw'>do</span>
|
744
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_nested_blobject'>nested_blobject</span>
|
745
|
+
<span class='id identifier rubyid_nested_blobject'>nested_blobject</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='symbol'>:remove_instance_variable</span><span class='comma'>,</span> <span class='symbol'>:@store_in_parent</span>
|
746
|
+
<span class='kw'>end</span>
|
747
|
+
|
748
|
+
<span class='id identifier rubyid_nested_blobject'>nested_blobject</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span> <span class='symbol'>:@store_in_parent</span><span class='comma'>,</span> <span class='id identifier rubyid_store_in_parent'>store_in_parent</span>
|
749
|
+
|
750
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_nested_blobject'>nested_blobject</span>
|
751
|
+
|
752
|
+
<span class='kw'>when</span> <span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\w+)=$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span>
|
753
|
+
<span class='comment'># the call is an attribute writer
|
754
|
+
</span>
|
755
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='symbol'>:__define_attribute__</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span>
|
756
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
757
|
+
|
758
|
+
<span class='kw'>when</span> <span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\w+)\?$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>0</span>
|
759
|
+
<span class='comment'># the call is an attribute checker
|
760
|
+
</span>
|
761
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='symbol'>:__define_attribute__</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span>
|
762
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_method'>method</span>
|
763
|
+
<span class='kw'>end</span>
|
764
|
+
|
765
|
+
<span class='kw'>super</span>
|
766
|
+
<span class='kw'>end</span></pre>
|
767
|
+
</td>
|
768
|
+
</tr>
|
769
|
+
</table>
|
770
|
+
</div>
|
771
|
+
|
772
|
+
</div>
|
773
|
+
|
774
|
+
|
775
|
+
<div id="class_method_details" class="method_details_list">
|
776
|
+
<h2>Class Method Details</h2>
|
777
|
+
|
778
|
+
|
779
|
+
<div class="method_details first">
|
780
|
+
<h3 class="signature first" id="from_json-class_method">
|
781
|
+
|
782
|
+
+ (<tt>Object</tt>) <strong>from_json</strong>(json)
|
783
|
+
|
784
|
+
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
</h3><div class="docstring">
|
789
|
+
<div class="discussion">
|
790
|
+
|
791
|
+
<p>get a Blobject from a json string if the yaml string describes an array, an
|
792
|
+
array will be returned</p>
|
793
|
+
|
794
|
+
|
795
|
+
</div>
|
796
|
+
</div>
|
797
|
+
<div class="tags">
|
798
|
+
|
799
|
+
|
800
|
+
</div><table class="source_code">
|
801
|
+
<tr>
|
802
|
+
<td>
|
803
|
+
<pre class="lines">
|
804
|
+
|
805
|
+
|
806
|
+
159
|
807
|
+
160
|
808
|
+
161
|
809
|
+
162</pre>
|
810
|
+
</td>
|
811
|
+
<td>
|
812
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 159</span>
|
813
|
+
|
814
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_json'>from_json</span> <span class='id identifier rubyid_json'>json</span>
|
815
|
+
|
816
|
+
<span class='id identifier rubyid___from_hash_or_array__'>__from_hash_or_array__</span><span class='lparen'>(</span><span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_json'>json</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
817
|
+
<span class='kw'>end</span></pre>
|
818
|
+
</td>
|
819
|
+
</tr>
|
820
|
+
</table>
|
821
|
+
</div>
|
822
|
+
|
823
|
+
<div class="method_details ">
|
824
|
+
<h3 class="signature " id="from_yaml-class_method">
|
825
|
+
|
826
|
+
+ (<tt>Object</tt>) <strong>from_yaml</strong>(yaml)
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
</h3><div class="docstring">
|
833
|
+
<div class="discussion">
|
834
|
+
|
835
|
+
<p>get a Blobject from a yaml string if the yaml string describes an array, an
|
836
|
+
array will be returned</p>
|
837
|
+
|
838
|
+
|
839
|
+
</div>
|
840
|
+
</div>
|
841
|
+
<div class="tags">
|
842
|
+
|
843
|
+
|
844
|
+
</div><table class="source_code">
|
845
|
+
<tr>
|
846
|
+
<td>
|
847
|
+
<pre class="lines">
|
848
|
+
|
849
|
+
|
850
|
+
166
|
851
|
+
167
|
852
|
+
168
|
853
|
+
169</pre>
|
854
|
+
</td>
|
855
|
+
<td>
|
856
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 166</span>
|
857
|
+
|
858
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_yaml'>from_yaml</span> <span class='id identifier rubyid_yaml'>yaml</span>
|
859
|
+
|
860
|
+
<span class='id identifier rubyid___from_hash_or_array__'>__from_hash_or_array__</span><span class='lparen'>(</span><span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_yaml'>yaml</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
861
|
+
<span class='kw'>end</span></pre>
|
862
|
+
</td>
|
863
|
+
</tr>
|
864
|
+
</table>
|
865
|
+
</div>
|
866
|
+
|
867
|
+
</div>
|
868
|
+
|
869
|
+
<div id="instance_method_details" class="method_details_list">
|
870
|
+
<h2>Instance Method Details</h2>
|
871
|
+
|
872
|
+
|
873
|
+
<div class="method_details first">
|
874
|
+
<h3 class="signature first" id="==-instance_method">
|
875
|
+
|
876
|
+
- (<tt>Object</tt>) <strong>==</strong>(other)
|
877
|
+
|
878
|
+
|
879
|
+
|
880
|
+
|
881
|
+
|
882
|
+
</h3><div class="docstring">
|
883
|
+
<div class="discussion">
|
884
|
+
|
885
|
+
<p>compares Blobjects to Blobjects or Hashes</p>
|
886
|
+
|
887
|
+
|
888
|
+
</div>
|
889
|
+
</div>
|
890
|
+
<div class="tags">
|
891
|
+
|
892
|
+
|
893
|
+
</div><table class="source_code">
|
894
|
+
<tr>
|
895
|
+
<td>
|
896
|
+
<pre class="lines">
|
897
|
+
|
898
|
+
|
899
|
+
114
|
900
|
+
115
|
901
|
+
116
|
902
|
+
117
|
903
|
+
118</pre>
|
904
|
+
</td>
|
905
|
+
<td>
|
906
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 114</span>
|
907
|
+
|
908
|
+
<span class='kw'>def</span> <span class='op'>==</span> <span class='id identifier rubyid_other'>other</span>
|
909
|
+
<span class='kw'>return</span> <span class='ivar'>@hash</span> <span class='op'>==</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span> <span class='kw'>if</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'><=</span> <span class='const'>Blobject</span>
|
910
|
+
<span class='kw'>return</span> <span class='ivar'>@hash</span> <span class='op'>==</span> <span class='id identifier rubyid_other'>other</span> <span class='kw'>if</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'><=</span> <span class='const'>Hash</span>
|
911
|
+
<span class='kw'>super</span>
|
912
|
+
<span class='kw'>end</span></pre>
|
913
|
+
</td>
|
914
|
+
</tr>
|
915
|
+
</table>
|
916
|
+
</div>
|
917
|
+
|
918
|
+
<div class="method_details ">
|
919
|
+
<h3 class="signature " id="[]-instance_method">
|
920
|
+
|
921
|
+
- (<tt>Object</tt>) <strong>[]</strong>(name)
|
922
|
+
|
923
|
+
|
924
|
+
|
925
|
+
|
926
|
+
|
927
|
+
</h3><div class="docstring">
|
928
|
+
<div class="discussion">
|
929
|
+
|
930
|
+
<p>hash-like access to the Blobject's attributes</p>
|
931
|
+
|
932
|
+
|
933
|
+
</div>
|
934
|
+
</div>
|
935
|
+
<div class="tags">
|
936
|
+
|
937
|
+
|
938
|
+
</div><table class="source_code">
|
939
|
+
<tr>
|
940
|
+
<td>
|
941
|
+
<pre class="lines">
|
942
|
+
|
943
|
+
|
944
|
+
121
|
945
|
+
122
|
946
|
+
123
|
947
|
+
124</pre>
|
948
|
+
</td>
|
949
|
+
<td>
|
950
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 121</span>
|
951
|
+
|
952
|
+
<span class='kw'>def</span> <span class='op'>[]</span> <span class='id identifier rubyid_name'>name</span>
|
953
|
+
|
954
|
+
<span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_name'>name</span>
|
955
|
+
<span class='kw'>end</span></pre>
|
956
|
+
</td>
|
957
|
+
</tr>
|
958
|
+
</table>
|
959
|
+
</div>
|
960
|
+
|
961
|
+
<div class="method_details ">
|
962
|
+
<h3 class="signature " id="[]=-instance_method">
|
963
|
+
|
964
|
+
- (<tt>Object</tt>) <strong>[]=</strong>(name, value)
|
965
|
+
|
966
|
+
|
967
|
+
|
968
|
+
|
969
|
+
|
970
|
+
</h3><div class="docstring">
|
971
|
+
<div class="discussion">
|
972
|
+
|
973
|
+
<p>hash-like attribtue setter</p>
|
974
|
+
|
975
|
+
|
976
|
+
</div>
|
977
|
+
</div>
|
978
|
+
<div class="tags">
|
979
|
+
|
980
|
+
|
981
|
+
</div><table class="source_code">
|
982
|
+
<tr>
|
983
|
+
<td>
|
984
|
+
<pre class="lines">
|
985
|
+
|
986
|
+
|
987
|
+
127
|
988
|
+
128
|
989
|
+
129
|
990
|
+
130</pre>
|
991
|
+
</td>
|
992
|
+
<td>
|
993
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 127</span>
|
994
|
+
|
995
|
+
<span class='kw'>def</span> <span class='op'>[]=</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span>
|
996
|
+
|
997
|
+
<span class='id identifier rubyid_send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span>
|
998
|
+
<span class='kw'>end</span></pre>
|
999
|
+
</td>
|
1000
|
+
</tr>
|
1001
|
+
</table>
|
1002
|
+
</div>
|
1003
|
+
|
1004
|
+
<div class="method_details ">
|
1005
|
+
<h3 class="signature " id="as_json-instance_method">
|
1006
|
+
|
1007
|
+
- (<tt>Object</tt>) <strong>as_json</strong>(*args)
|
1008
|
+
|
1009
|
+
|
1010
|
+
|
1011
|
+
|
1012
|
+
|
1013
|
+
</h3><div class="docstring">
|
1014
|
+
<div class="discussion">
|
1015
|
+
|
1016
|
+
<p>returns a hash which can be serialized as json. this is for use in rails
|
1017
|
+
controllers: `render json: blobject`</p>
|
1018
|
+
|
1019
|
+
|
1020
|
+
</div>
|
1021
|
+
</div>
|
1022
|
+
<div class="tags">
|
1023
|
+
|
1024
|
+
|
1025
|
+
</div><table class="source_code">
|
1026
|
+
<tr>
|
1027
|
+
<td>
|
1028
|
+
<pre class="lines">
|
1029
|
+
|
1030
|
+
|
1031
|
+
141
|
1032
|
+
142
|
1033
|
+
143
|
1034
|
+
144</pre>
|
1035
|
+
</td>
|
1036
|
+
<td>
|
1037
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 141</span>
|
1038
|
+
|
1039
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
|
1040
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span> <span class='symbol'>:as_json</span>
|
1041
|
+
<span class='id identifier rubyid_to_hash'>to_hash</span>
|
1042
|
+
<span class='kw'>end</span></pre>
|
1043
|
+
</td>
|
1044
|
+
</tr>
|
1045
|
+
</table>
|
1046
|
+
</div>
|
1047
|
+
|
1048
|
+
<div class="method_details ">
|
1049
|
+
<h3 class="signature " id="freeze-instance_method">
|
1050
|
+
|
1051
|
+
- (<tt>Object</tt>) <strong>freeze</strong>
|
1052
|
+
|
1053
|
+
|
1054
|
+
|
1055
|
+
|
1056
|
+
|
1057
|
+
</h3><div class="docstring">
|
1058
|
+
<div class="discussion">
|
1059
|
+
|
1060
|
+
<p>freeze a Blobject to prevent it being modified</p>
|
1061
|
+
|
1062
|
+
|
1063
|
+
</div>
|
1064
|
+
</div>
|
1065
|
+
<div class="tags">
|
1066
|
+
|
1067
|
+
|
1068
|
+
</div><table class="source_code">
|
1069
|
+
<tr>
|
1070
|
+
<td>
|
1071
|
+
<pre class="lines">
|
1072
|
+
|
1073
|
+
|
1074
|
+
133
|
1075
|
+
134
|
1076
|
+
135
|
1077
|
+
136
|
1078
|
+
137</pre>
|
1079
|
+
</td>
|
1080
|
+
<td>
|
1081
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 133</span>
|
1082
|
+
|
1083
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_freeze'>freeze</span>
|
1084
|
+
<span class='id identifier rubyid___visit_subtree__'>__visit_subtree__</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='op'>|</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span> <span class='rbrace'>}</span>
|
1085
|
+
<span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
1086
|
+
<span class='kw'>super</span>
|
1087
|
+
<span class='kw'>end</span></pre>
|
1088
|
+
</td>
|
1089
|
+
</tr>
|
1090
|
+
</table>
|
1091
|
+
</div>
|
1092
|
+
|
1093
|
+
<div class="method_details ">
|
1094
|
+
<h3 class="signature " id="hash-instance_method">
|
1095
|
+
|
1096
|
+
- (<tt>Object</tt>) <strong>hash</strong>
|
1097
|
+
|
1098
|
+
|
1099
|
+
|
1100
|
+
|
1101
|
+
|
1102
|
+
</h3><div class="docstring">
|
1103
|
+
<div class="discussion">
|
1104
|
+
|
1105
|
+
<p>access the internal hash. be careful, this is <em>not</em> a copy</p>
|
1106
|
+
|
1107
|
+
|
1108
|
+
</div>
|
1109
|
+
</div>
|
1110
|
+
<div class="tags">
|
1111
|
+
|
1112
|
+
|
1113
|
+
</div><table class="source_code">
|
1114
|
+
<tr>
|
1115
|
+
<td>
|
1116
|
+
<pre class="lines">
|
1117
|
+
|
1118
|
+
|
1119
|
+
42
|
1120
|
+
43
|
1121
|
+
44
|
1122
|
+
45</pre>
|
1123
|
+
</td>
|
1124
|
+
<td>
|
1125
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 42</span>
|
1126
|
+
|
1127
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_hash'>hash</span>
|
1128
|
+
|
1129
|
+
<span class='ivar'>@hash</span>
|
1130
|
+
<span class='kw'>end</span></pre>
|
1131
|
+
</td>
|
1132
|
+
</tr>
|
1133
|
+
</table>
|
1134
|
+
</div>
|
1135
|
+
|
1136
|
+
<div class="method_details ">
|
1137
|
+
<h3 class="signature " id="inspect-instance_method">
|
1138
|
+
|
1139
|
+
- (<tt>Object</tt>) <strong>inspect</strong>
|
1140
|
+
|
1141
|
+
|
1142
|
+
|
1143
|
+
|
1144
|
+
|
1145
|
+
</h3><div class="docstring">
|
1146
|
+
<div class="discussion">
|
1147
|
+
|
1148
|
+
<p>delegates to the internal Hash</p>
|
1149
|
+
|
1150
|
+
|
1151
|
+
</div>
|
1152
|
+
</div>
|
1153
|
+
<div class="tags">
|
1154
|
+
|
1155
|
+
|
1156
|
+
</div><table class="source_code">
|
1157
|
+
<tr>
|
1158
|
+
<td>
|
1159
|
+
<pre class="lines">
|
1160
|
+
|
1161
|
+
|
1162
|
+
36
|
1163
|
+
37
|
1164
|
+
38
|
1165
|
+
39</pre>
|
1166
|
+
</td>
|
1167
|
+
<td>
|
1168
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 36</span>
|
1169
|
+
|
1170
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span>
|
1171
|
+
|
1172
|
+
<span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
|
1173
|
+
<span class='kw'>end</span></pre>
|
1174
|
+
</td>
|
1175
|
+
</tr>
|
1176
|
+
</table>
|
1177
|
+
</div>
|
1178
|
+
|
1179
|
+
<div class="method_details ">
|
1180
|
+
<h3 class="signature " id="respond_to?-instance_method">
|
1181
|
+
|
1182
|
+
- (<tt>Boolean</tt>) <strong>respond_to?</strong>(method)
|
1183
|
+
|
1184
|
+
|
1185
|
+
|
1186
|
+
|
1187
|
+
|
1188
|
+
</h3><div class="docstring">
|
1189
|
+
<div class="discussion">
|
1190
|
+
|
1191
|
+
|
1192
|
+
</div>
|
1193
|
+
</div>
|
1194
|
+
<div class="tags">
|
1195
|
+
|
1196
|
+
<p class="tag_title">Returns:</p>
|
1197
|
+
<ul class="return">
|
1198
|
+
|
1199
|
+
<li>
|
1200
|
+
|
1201
|
+
|
1202
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1203
|
+
|
1204
|
+
|
1205
|
+
|
1206
|
+
</li>
|
1207
|
+
|
1208
|
+
</ul>
|
1209
|
+
|
1210
|
+
</div><table class="source_code">
|
1211
|
+
<tr>
|
1212
|
+
<td>
|
1213
|
+
<pre class="lines">
|
1214
|
+
|
1215
|
+
|
1216
|
+
101
|
1217
|
+
102
|
1218
|
+
103
|
1219
|
+
104
|
1220
|
+
105
|
1221
|
+
106
|
1222
|
+
107
|
1223
|
+
108
|
1224
|
+
109
|
1225
|
+
110
|
1226
|
+
111</pre>
|
1227
|
+
</td>
|
1228
|
+
<td>
|
1229
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 101</span>
|
1230
|
+
|
1231
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span> <span class='id identifier rubyid_method'>method</span>
|
1232
|
+
|
1233
|
+
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_methods'>methods</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
|
1234
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='const'>ProhibitedNames</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
|
1235
|
+
|
1236
|
+
<span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
1237
|
+
|
1238
|
+
<span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\w+)=$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\w+)\?$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\w+$</span><span class='regexp_end'>/</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_r'>r</span><span class='op'>|</span>
|
1239
|
+
<span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
|
1240
|
+
<span class='kw'>end</span>
|
1241
|
+
<span class='kw'>end</span></pre>
|
1242
|
+
</td>
|
1243
|
+
</tr>
|
1244
|
+
</table>
|
1245
|
+
</div>
|
1246
|
+
|
1247
|
+
<div class="method_details ">
|
1248
|
+
<h3 class="signature " id="to_hash-instance_method">
|
1249
|
+
|
1250
|
+
- (<tt>Object</tt>) <strong>to_hash</strong>
|
1251
|
+
|
1252
|
+
|
1253
|
+
|
1254
|
+
|
1255
|
+
|
1256
|
+
</h3><div class="docstring">
|
1257
|
+
<div class="discussion">
|
1258
|
+
|
1259
|
+
<p>creates a recursive copy of the internal hash</p>
|
1260
|
+
|
1261
|
+
|
1262
|
+
</div>
|
1263
|
+
</div>
|
1264
|
+
<div class="tags">
|
1265
|
+
|
1266
|
+
|
1267
|
+
</div><table class="source_code">
|
1268
|
+
<tr>
|
1269
|
+
<td>
|
1270
|
+
<pre class="lines">
|
1271
|
+
|
1272
|
+
|
1273
|
+
48
|
1274
|
+
49
|
1275
|
+
50
|
1276
|
+
51
|
1277
|
+
52
|
1278
|
+
53
|
1279
|
+
54
|
1280
|
+
55</pre>
|
1281
|
+
</td>
|
1282
|
+
<td>
|
1283
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 48</span>
|
1284
|
+
|
1285
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span>
|
1286
|
+
|
1287
|
+
<span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
|
1288
|
+
<span class='id identifier rubyid___visit_subtree__'>__visit_subtree__</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
|
1289
|
+
<span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span> <span class='kw'>if</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span> <span class='symbol'>:to_hash</span>
|
1290
|
+
<span class='kw'>end</span>
|
1291
|
+
<span class='id identifier rubyid_h'>h</span>
|
1292
|
+
<span class='kw'>end</span></pre>
|
1293
|
+
</td>
|
1294
|
+
</tr>
|
1295
|
+
</table>
|
1296
|
+
</div>
|
1297
|
+
|
1298
|
+
<div class="method_details ">
|
1299
|
+
<h3 class="signature " id="to_json-instance_method">
|
1300
|
+
|
1301
|
+
- (<tt>Object</tt>) <strong>to_json</strong>(*args)
|
1302
|
+
|
1303
|
+
|
1304
|
+
|
1305
|
+
|
1306
|
+
|
1307
|
+
</h3><div class="docstring">
|
1308
|
+
<div class="discussion">
|
1309
|
+
|
1310
|
+
<p>serialize the Blobject as a json string</p>
|
1311
|
+
|
1312
|
+
|
1313
|
+
</div>
|
1314
|
+
</div>
|
1315
|
+
<div class="tags">
|
1316
|
+
|
1317
|
+
|
1318
|
+
</div><table class="source_code">
|
1319
|
+
<tr>
|
1320
|
+
<td>
|
1321
|
+
<pre class="lines">
|
1322
|
+
|
1323
|
+
|
1324
|
+
147
|
1325
|
+
148
|
1326
|
+
149</pre>
|
1327
|
+
</td>
|
1328
|
+
<td>
|
1329
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 147</span>
|
1330
|
+
|
1331
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_json'>to_json</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
|
1332
|
+
<span class='id identifier rubyid_as_json'>as_json</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
|
1333
|
+
<span class='kw'>end</span></pre>
|
1334
|
+
</td>
|
1335
|
+
</tr>
|
1336
|
+
</table>
|
1337
|
+
</div>
|
1338
|
+
|
1339
|
+
<div class="method_details ">
|
1340
|
+
<h3 class="signature " id="to_yaml-instance_method">
|
1341
|
+
|
1342
|
+
- (<tt>Object</tt>) <strong>to_yaml</strong>
|
1343
|
+
|
1344
|
+
|
1345
|
+
|
1346
|
+
|
1347
|
+
|
1348
|
+
</h3><div class="docstring">
|
1349
|
+
<div class="discussion">
|
1350
|
+
|
1351
|
+
<p>serialize the Blobject as a yaml string</p>
|
1352
|
+
|
1353
|
+
|
1354
|
+
</div>
|
1355
|
+
</div>
|
1356
|
+
<div class="tags">
|
1357
|
+
|
1358
|
+
|
1359
|
+
</div><table class="source_code">
|
1360
|
+
<tr>
|
1361
|
+
<td>
|
1362
|
+
<pre class="lines">
|
1363
|
+
|
1364
|
+
|
1365
|
+
152
|
1366
|
+
153
|
1367
|
+
154
|
1368
|
+
155</pre>
|
1369
|
+
</td>
|
1370
|
+
<td>
|
1371
|
+
<pre class="code"><span class="info file"># File 'lib/blobject.rb', line 152</span>
|
1372
|
+
|
1373
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_yaml'>to_yaml</span>
|
1374
|
+
|
1375
|
+
<span class='id identifier rubyid_as_yaml'>as_yaml</span><span class='period'>.</span><span class='id identifier rubyid_to_yaml'>to_yaml</span>
|
1376
|
+
<span class='kw'>end</span></pre>
|
1377
|
+
</td>
|
1378
|
+
</tr>
|
1379
|
+
</table>
|
1380
|
+
</div>
|
1381
|
+
|
1382
|
+
</div>
|
1383
|
+
|
1384
|
+
</div>
|
1385
|
+
|
1386
|
+
<div id="footer">
|
1387
|
+
Generated on Thu Jun 7 00:25:32 2012 by
|
1388
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1389
|
+
0.8.1 (ruby-1.9.3).
|
1390
|
+
</div>
|
1391
|
+
|
1392
|
+
</body>
|
1393
|
+
</html>
|