blobject 0.3.7 → 0.4.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 708992c07f068c79b12ba29d62268cdf002e0eb2
4
+ data.tar.gz: bbeef31664ae8ab9dced3e8db1ea2ccb06f26f41
5
+ SHA512:
6
+ metadata.gz: bdafb48ddfdb1bffd175e7374b4a19e27ac0de26fae8e0f654ccf12768057a2a8069425eb2fc3d8a24e77525897dea0f9a1b07a1d53c2d31a29e66345c965cdb
7
+ data.tar.gz: 5c474f2ec4bb07a7090f23641763d490fdac826a0ed009594410e149eac2951d60e2398c9ac351ebc965465209860dfcfbb467054e24a7816e827ac827733241
data/.gitignore CHANGED
File without changes
data/.pryrc CHANGED
@@ -1,7 +1,4 @@
1
- $:.push File.expand_path('../lib', __FILE__)
2
- require 'debugger'
3
- require 'blobject'
4
-
5
- def reload!
6
- load 'blobject.rb'
7
- end
1
+ Pry.commands.alias_command 'c', 'continue'
2
+ Pry.commands.alias_command 's', 'step'
3
+ Pry.commands.alias_command 'n', 'next'
4
+ Pry.commands.alias_command '...', 'whereami'
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup markdown
2
+ --readme README.markdown
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
@@ -1,42 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blobject (0.3.6)
4
+ blobject (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- ansi (1.4.2)
10
- builder (3.0.0)
11
- coderay (1.0.6)
12
- columnize (0.3.6)
13
- debugger (1.1.3)
14
- columnize (>= 0.3.1)
15
- debugger-linecache (~> 1.1.1)
16
- debugger-ruby_core_source (~> 1.1.2)
17
- debugger-linecache (1.1.1)
18
- debugger-ruby_core_source (>= 1.1.1)
19
- debugger-ruby_core_source (1.1.3)
20
- method_source (0.7.1)
21
- minitest (3.0.1)
22
- minitest-reporters (0.7.1)
9
+ ansi (1.4.3)
10
+ builder (3.2.2)
11
+ coderay (1.1.0)
12
+ method_source (0.8.2)
13
+ minitest (5.3.3)
14
+ minitest-reporters (1.0.3)
23
15
  ansi
24
16
  builder
25
- minitest (>= 2.0, < 4.0)
17
+ minitest (>= 5.0)
26
18
  ruby-progressbar
27
- pry (0.9.9.6)
28
- coderay (~> 1.0.5)
29
- method_source (~> 0.7.1)
30
- slop (>= 2.4.4, < 3)
31
- ruby-progressbar (0.0.10)
32
- slop (2.4.4)
19
+ pry (0.9.12.6)
20
+ coderay (~> 1.0)
21
+ method_source (~> 0.8)
22
+ slop (~> 3.4)
23
+ pry-nav (0.2.3)
24
+ pry (~> 0.9.10)
25
+ ruby-progressbar (1.4.2)
26
+ slop (3.5.0)
33
27
 
34
28
  PLATFORMS
35
29
  ruby
36
30
 
37
31
  DEPENDENCIES
38
32
  blobject!
39
- debugger
40
33
  minitest
41
34
  minitest-reporters
42
35
  pry
36
+ pry-nav
data/README.markdown CHANGED
@@ -1,10 +1,50 @@
1
- ![](https://github.com/sjltaylor/blobject/raw/master/assets/blobject.png)
2
- ![](https://github.com/sjltaylor/blobject/raw/master/assets/blob_defn.png)
1
+ ![](https://github.com/sjltaylor/blobject/raw/master/assets/blobject.png)
3
2
 
4
- Getting started: `http://sjltaylor.com/blobject'
3
+ Rdocs: [http://sjltaylor.github.com/blobject](http://sjltaylor.github.com/blobject)
5
4
 
6
5
  ## About
7
6
 
7
+ Consider the following json sample...
8
+
9
+ {
10
+ "device_id": 63354,
11
+ "channel_no": 6,
12
+ "interval_ms": 15000,
13
+ "readings": [
14
+ {
15
+ "value": 14232,
16
+ "time": 1339880802
17
+ },
18
+ {
19
+ "value": 14232,
20
+ "time": 1339880817
21
+ }
22
+ ],
23
+ "calibration": {
24
+ "staff": {
25
+ "name": {
26
+ "first": "Carl",
27
+ "middle_initial": "I",
28
+ "second": "Brator"
29
+ }
30
+ },
31
+ "last_calibration": "2010-06-16T22:06:42+01:00"
32
+ }
33
+ }
34
+
35
+ Blobject let's you do this (complete code listing, no predefined data structures):
36
+
37
+
38
+ data = Blobject.from_json HTTParty.get('https://raw.github.com/sjltaylor/blobject/master/spec/sample_data/sample3.json')
39
+
40
+ full_name = "#{data.calibration.staff.name.first}#{data.calibration.staff.name.middle_initial}#{data.calibration.staff.name.second}".capitalize
41
+ => "Calibrator"
42
+
43
+ last_reading = data.readings.last.value if data.readings?
44
+ => 14232
45
+
46
+
47
+ Blobject is convenient to creating json payloads too.
8
48
  Blobjects are *freeform* which means you can do this...
9
49
 
10
50
  data = Blobject.new
@@ -68,6 +108,23 @@ You can work with JSON data using `Blobject.from_json` and `Blobject#to_json`, i
68
108
 
69
109
  You can work with YAML data using `Blobject.from_yaml` and `Blobject#to_yaml`.
70
110
 
111
+ ## Try it out...
112
+
113
+ 1. Install the gem (ruby 1.9.2+ required): `sh <(curl https://raw.github.com/sjltaylor/blobject/master/try_blobject.sh)`
114
+ 2. Load data from an api...
115
+ payload = Blobject.from_json HTTParty.get('https://raw.github.com/sjltaylor/blobject/master/spec/sample_data/sample3.json')
116
+ 3. Inspect it
117
+ payload.calibration.staff.name
118
+ => {:first=>"Carl", :middle_initial=>"I", :second=>"Brator"}
119
+ 4. Test for optional data members
120
+ payload.channel_no?
121
+ => true
122
+ payload.something_that_is_not_there?
123
+ => false
124
+ 5. Draw your own payload
125
+ mine = Blobject.new my: {data: 123}
126
+ mine.to_json
127
+ => "{\"my\":{\"data\":123}}"
71
128
 
72
129
  ## Used for Configuration
73
130
 
@@ -104,7 +161,7 @@ Using a blobject we can easily avoid having to refactor our code...
104
161
  end
105
162
 
106
163
 
107
- ## Serializing & Deserializing
164
+ ## Serialization
108
165
 
109
166
  Blobjects can be used to easily build complex payloads.
110
167
 
@@ -209,3 +266,6 @@ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
209
266
 
210
267
  Copyright (c) 2012 Sam Taylor. See LICENSE.txt for
211
268
  further details.
269
+
270
+ ![](https://github.com/sjltaylor/blobject/raw/master/assets/blob_defn.png)
271
+
data/Rakefile CHANGED
File without changes
data/assets/blob_defn.png CHANGED
File without changes
data/assets/blobject.png CHANGED
File without changes
data/benchmarks/results CHANGED
File without changes
data/blobject.gemspec CHANGED
@@ -13,12 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{Blobject provides a free flowing syntax for creating blobs of data.}
14
14
 
15
15
  s.rubyforge_project = "blobject"
16
-
16
+
17
17
  s.add_development_dependency 'minitest'
18
18
  s.add_development_dependency 'minitest-reporters'
19
19
  s.add_development_dependency 'pry'
20
- s.add_development_dependency 'debugger'
21
-
20
+ s.add_development_dependency 'pry-nav'
21
+
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
24
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
data/blobject.psd CHANGED
File without changes
data/doc/Blobject.html CHANGED
@@ -103,8 +103,7 @@
103
103
 
104
104
  <h2>Overview</h2><div class="docstring">
105
105
  <div class="discussion">
106
-
107
- <p>Wraps a hash to provide arbitrarily nested, object-style attribute access</p>
106
+ <p>Wraps a hash to provide arbitrarily nested object-style attribute access</p>
108
107
 
109
108
 
110
109
  </div>
@@ -120,9 +119,8 @@
120
119
  <dt id="ProhibitedNames-constant" class="">ProhibitedNames =
121
120
  <div class="docstring">
122
121
  <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>
122
+ <p>filter :to<em>ary else Blobject#to</em>ary returns a
123
+ blobject which is not cool, especially if you are puts.</p>
126
124
 
127
125
 
128
126
  </div>
@@ -135,9 +133,19 @@ especially if you are puts.</p>
135
133
  <dd><pre class="code"><span class='lbracket'>[</span><span class='symbol'>:to_ary</span><span class='rbracket'>]</span></pre></dd>
136
134
 
137
135
  <dt id="VERSION-constant" class="">VERSION =
138
-
136
+ <div class="docstring">
137
+ <div class="discussion">
138
+ <p>semver gem version</p>
139
+
140
+
141
+ </div>
142
+ </div>
143
+ <div class="tags">
144
+
145
+
146
+ </div>
139
147
  </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>
148
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.3.8</span><span class='tstring_end'>'</span></span></pre></dd>
141
149
 
142
150
  </dl>
143
151
 
@@ -173,9 +181,7 @@ especially if you are puts.</p>
173
181
 
174
182
 
175
183
 
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>
184
+ <span class="summary_desc"><div class='inline'><p>get a Blobject from a json string, if the yaml string describes an array, an array will be returned.</p>
179
185
  </div></span>
180
186
 
181
187
  </li>
@@ -198,9 +204,7 @@ array will be returned.</p>
198
204
 
199
205
 
200
206
 
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>
207
+ <span class="summary_desc"><div class='inline'><p>get a Blobject from a yaml string, if the yaml string describes an array, an array will be returned.</p>
204
208
  </div></span>
205
209
 
206
210
  </li>
@@ -232,8 +236,7 @@ array will be returned.</p>
232
236
 
233
237
 
234
238
 
235
- <span class="summary_desc"><div class='inline'>
236
- <p>compares Blobjects to Blobjects or Hashes.</p>
239
+ <span class="summary_desc"><div class='inline'><p>compares Blobjects to Blobjects or Hashes for equality.</p>
237
240
  </div></span>
238
241
 
239
242
  </li>
@@ -256,8 +259,7 @@ array will be returned.</p>
256
259
 
257
260
 
258
261
 
259
- <span class="summary_desc"><div class='inline'>
260
- <p>hash-like access to the Blobject's attributes.</p>
262
+ <span class="summary_desc"><div class='inline'><p>hash-like access to the Blobject&#39;s attributes.</p>
261
263
  </div></span>
262
264
 
263
265
  </li>
@@ -280,8 +282,7 @@ array will be returned.</p>
280
282
 
281
283
 
282
284
 
283
- <span class="summary_desc"><div class='inline'>
284
- <p>hash-like attribtue setter.</p>
285
+ <span class="summary_desc"><div class='inline'><p>hash-like attribute setter.</p>
285
286
  </div></span>
286
287
 
287
288
  </li>
@@ -304,8 +305,30 @@ array will be returned.</p>
304
305
 
305
306
 
306
307
 
307
- <span class="summary_desc"><div class='inline'>
308
- <p>returns a hash which can be serialized as json.</p>
308
+ <span class="summary_desc"><div class='inline'><p>for rails: <code>render json: blobject</code>.</p>
309
+ </div></span>
310
+
311
+ </li>
312
+
313
+
314
+ <li class="public ">
315
+ <span class="summary_signature">
316
+
317
+ <a href="#empty%3F-instance_method" title="#empty? (instance method)">- (Boolean) <strong>empty?</strong> </a>
318
+
319
+
320
+
321
+ </span>
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+ <span class="summary_desc"><div class='inline'><p>indicates whether the blobject contains any data.</p>
309
332
  </div></span>
310
333
 
311
334
  </li>
@@ -328,8 +351,30 @@ array will be returned.</p>
328
351
 
329
352
 
330
353
 
331
- <span class="summary_desc"><div class='inline'>
332
- <p>freeze a Blobject to prevent it being modified.</p>
354
+ <span class="summary_desc"><div class='inline'><p>freeze a Blobject to prevent it being modified.</p>
355
+ </div></span>
356
+
357
+ </li>
358
+
359
+
360
+ <li class="public ">
361
+ <span class="summary_signature">
362
+
363
+ <a href="#freeze_r-instance_method" title="#freeze_r (instance method)">- (Object) <strong>freeze_r</strong> </a>
364
+
365
+
366
+
367
+ </span>
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+ <span class="summary_desc"><div class='inline'><p>recursively freeze the Blobject include nest Blobjects in arrays.</p>
333
378
  </div></span>
334
379
 
335
380
  </li>
@@ -352,8 +397,7 @@ array will be returned.</p>
352
397
 
353
398
 
354
399
 
355
- <span class="summary_desc"><div class='inline'>
356
- <p>access the internal hash.</p>
400
+ <span class="summary_desc"><div class='inline'><p>access the internal hash.</p>
357
401
  </div></span>
358
402
 
359
403
  </li>
@@ -378,9 +422,8 @@ array will be returned.</p>
378
422
 
379
423
 
380
424
 
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>
425
+ <span class="summary_desc"><div class='inline'><p>pass an optional hash of values to preload
426
+ you can also pass a block, the new Blobject will be yield.</p>
384
427
  </div></span>
385
428
 
386
429
  </li>
@@ -403,8 +446,7 @@ new Blobject will be yield.</p>
403
446
 
404
447
 
405
448
 
406
- <span class="summary_desc"><div class='inline'>
407
- <p>delegates to the internal Hash.</p>
449
+ <span class="summary_desc"><div class='inline'><p>delegates to the internal Hash.</p>
408
450
  </div></span>
409
451
 
410
452
  </li>
@@ -427,8 +469,7 @@ new Blobject will be yield.</p>
427
469
 
428
470
 
429
471
 
430
- <span class="summary_desc"><div class='inline'>
431
- <p>method_missing is only called the first time an attribute is used.</p>
472
+ <span class="summary_desc"><div class='inline'><p>method_missing is only called the first time an attribute is used.</p>
432
473
  </div></span>
433
474
 
434
475
  </li>
@@ -473,8 +514,7 @@ new Blobject will be yield.</p>
473
514
 
474
515
 
475
516
 
476
- <span class="summary_desc"><div class='inline'>
477
- <p>creates a recursive copy of the internal hash.</p>
517
+ <span class="summary_desc"><div class='inline'><p>creates a recursive copy of the internal hash.</p>
478
518
  </div></span>
479
519
 
480
520
  </li>
@@ -497,8 +537,7 @@ new Blobject will be yield.</p>
497
537
 
498
538
 
499
539
 
500
- <span class="summary_desc"><div class='inline'>
501
- <p>serialize the Blobject as a json string.</p>
540
+ <span class="summary_desc"><div class='inline'><p>serialize the Blobject as a json string.</p>
502
541
  </div></span>
503
542
 
504
543
  </li>
@@ -521,8 +560,7 @@ new Blobject will be yield.</p>
521
560
 
522
561
 
523
562
 
524
- <span class="summary_desc"><div class='inline'>
525
- <p>serialize the Blobject as a yaml string.</p>
563
+ <span class="summary_desc"><div class='inline'><p>serialize the Blobject as a yaml string.</p>
526
564
  </div></span>
527
565
 
528
566
  </li>
@@ -545,9 +583,8 @@ new Blobject will be yield.</p>
545
583
 
546
584
  </h3><div class="docstring">
547
585
  <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>
586
+ <p>pass an optional hash of values to preload
587
+ you can also pass a block, the new Blobject will be yield</p>
551
588
 
552
589
 
553
590
  </div>
@@ -580,8 +617,7 @@ new Blobject will be yield</p>
580
617
 
581
618
 
582
619
  &mdash;
583
- <div class='inline'>
584
- <p>the object that the method was called on</p>
620
+ <div class='inline'><p>the object that the method was called on</p>
585
621
  </div>
586
622
 
587
623
  </li>
@@ -608,32 +644,22 @@ new Blobject will be yield</p>
608
644
  25
609
645
  26
610
646
  27
611
- 28
612
- 29
613
- 30
614
- 31
615
- 32
616
- 33</pre>
647
+ 28</pre>
617
648
  </td>
618
649
  <td>
619
650
  <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 14</span>
620
651
 
621
652
  <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
653
 
623
- <span class='ivar'>@hash</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
654
+ <span class='ivar'>@hash</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
624
655
 
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'>&lt;=</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>
656
+ <span class='id identifier rubyid_hash'>hash</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='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
657
+ <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> <span class='kw'>unless</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Symbol</span>
658
+ <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>
631
659
  <span class='kw'>end</span>
632
660
 
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'>&lt;=</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>
661
+ <span class='ivar'>@hash</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_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
662
+ <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='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='lparen'>(</span><span class='symbol'>:__blobjectify__</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
637
663
  <span class='kw'>end</span>
638
664
 
639
665
  <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>
@@ -662,9 +688,8 @@ new Blobject will be yield</p>
662
688
 
663
689
  </h3><div class="docstring">
664
690
  <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>
691
+ <p>method_missing is only called the first time an attribute is used. successive calls use
692
+ memoized getters, setters and checkers</p>
668
693
 
669
694
 
670
695
  </div>
@@ -718,7 +743,8 @@ successive calls use memoized getters, setters and checkers</p>
718
743
  96
719
744
  97
720
745
  98
721
- 99</pre>
746
+ 99
747
+ 100</pre>
722
748
  </td>
723
749
  <td>
724
750
  <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 59</span>
@@ -731,13 +757,14 @@ successive calls use memoized getters, setters and checkers</p>
731
757
  <span class='comment'># assignment in conditionals is usually a bad smell, here it helps minimize regex matching
732
758
  </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'>&amp;&amp;</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
759
  <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
-
760
+ </span>
761
+ <span class='kw'>return</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><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</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>
736
762
  <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
763
 
738
764
  <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
765
 
740
- <span class='id identifier rubyid_parent'>parent</span> <span class='op'>=</span> <span class='kw'>self</span>
766
+ <span class='comment'># close the scope for storing call chain
767
+ </span> <span class='id identifier rubyid_parent'>parent</span> <span class='op'>=</span> <span class='kw'>self</span>
741
768
  <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
769
 
743
770
  <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>
@@ -787,9 +814,7 @@ successive calls use memoized getters, setters and checkers</p>
787
814
 
788
815
  </h3><div class="docstring">
789
816
  <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>
817
+ <p>get a Blobject from a json string, if the yaml string describes an array, an array will be returned</p>
793
818
 
794
819
 
795
820
  </div>
@@ -803,17 +828,17 @@ array will be returned</p>
803
828
  <pre class="lines">
804
829
 
805
830
 
806
- 159
807
- 160
808
- 161
809
- 162</pre>
831
+ 164
832
+ 165
833
+ 166
834
+ 167</pre>
810
835
  </td>
811
836
  <td>
812
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 159</span>
837
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 164</span>
813
838
 
814
839
  <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
840
 
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>
841
+ <span class='id identifier rubyid___blobjectify__'>__blobjectify__</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
842
  <span class='kw'>end</span></pre>
818
843
  </td>
819
844
  </tr>
@@ -831,9 +856,7 @@ array will be returned</p>
831
856
 
832
857
  </h3><div class="docstring">
833
858
  <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>
859
+ <p>get a Blobject from a yaml string, if the yaml string describes an array, an array will be returned</p>
837
860
 
838
861
 
839
862
  </div>
@@ -847,17 +870,17 @@ array will be returned</p>
847
870
  <pre class="lines">
848
871
 
849
872
 
850
- 166
851
- 167
852
- 168
853
- 169</pre>
873
+ 170
874
+ 171
875
+ 172
876
+ 173</pre>
854
877
  </td>
855
878
  <td>
856
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 166</span>
879
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 170</span>
857
880
 
858
881
  <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
882
 
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>
883
+ <span class='id identifier rubyid___blobjectify__'>__blobjectify__</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
884
  <span class='kw'>end</span></pre>
862
885
  </td>
863
886
  </tr>
@@ -881,8 +904,7 @@ array will be returned</p>
881
904
 
882
905
  </h3><div class="docstring">
883
906
  <div class="discussion">
884
-
885
- <p>compares Blobjects to Blobjects or Hashes</p>
907
+ <p>compares Blobjects to Blobjects or Hashes for equality</p>
886
908
 
887
909
 
888
910
  </div>
@@ -896,14 +918,14 @@ array will be returned</p>
896
918
  <pre class="lines">
897
919
 
898
920
 
899
- 114
900
921
  115
901
922
  116
902
923
  117
903
- 118</pre>
924
+ 118
925
+ 119</pre>
904
926
  </td>
905
927
  <td>
906
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 114</span>
928
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 115</span>
907
929
 
908
930
  <span class='kw'>def</span> <span class='op'>==</span> <span class='id identifier rubyid_other'>other</span>
909
931
  <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'>&lt;=</span> <span class='const'>Blobject</span>
@@ -926,8 +948,7 @@ array will be returned</p>
926
948
 
927
949
  </h3><div class="docstring">
928
950
  <div class="discussion">
929
-
930
- <p>hash-like access to the Blobject's attributes</p>
951
+ <p>hash-like access to the Blobject&#39;s attributes</p>
931
952
 
932
953
 
933
954
  </div>
@@ -941,13 +962,13 @@ array will be returned</p>
941
962
  <pre class="lines">
942
963
 
943
964
 
944
- 121
945
965
  122
946
966
  123
947
- 124</pre>
967
+ 124
968
+ 125</pre>
948
969
  </td>
949
970
  <td>
950
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 121</span>
971
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 122</span>
951
972
 
952
973
  <span class='kw'>def</span> <span class='op'>[]</span> <span class='id identifier rubyid_name'>name</span>
953
974
 
@@ -969,8 +990,7 @@ array will be returned</p>
969
990
 
970
991
  </h3><div class="docstring">
971
992
  <div class="discussion">
972
-
973
- <p>hash-like attribtue setter</p>
993
+ <p>hash-like attribute setter</p>
974
994
 
975
995
 
976
996
  </div>
@@ -984,13 +1004,13 @@ array will be returned</p>
984
1004
  <pre class="lines">
985
1005
 
986
1006
 
987
- 127
988
1007
  128
989
1008
  129
990
- 130</pre>
1009
+ 130
1010
+ 131</pre>
991
1011
  </td>
992
1012
  <td>
993
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 127</span>
1013
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 128</span>
994
1014
 
995
1015
  <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
1016
 
@@ -1012,9 +1032,7 @@ array will be returned</p>
1012
1032
 
1013
1033
  </h3><div class="docstring">
1014
1034
  <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>
1035
+ <p>for rails: <code>render json: blobject</code></p>
1018
1036
 
1019
1037
 
1020
1038
  </div>
@@ -1028,13 +1046,13 @@ controllers: `render json: blobject`</p>
1028
1046
  <pre class="lines">
1029
1047
 
1030
1048
 
1031
- 141
1032
- 142
1033
- 143
1034
- 144</pre>
1049
+ 147
1050
+ 148
1051
+ 149
1052
+ 150</pre>
1035
1053
  </td>
1036
1054
  <td>
1037
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 141</span>
1055
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 147</span>
1038
1056
 
1039
1057
  <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
1058
  <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>
@@ -1043,6 +1061,59 @@ controllers: `render json: blobject`</p>
1043
1061
  </td>
1044
1062
  </tr>
1045
1063
  </table>
1064
+ </div>
1065
+
1066
+ <div class="method_details ">
1067
+ <h3 class="signature " id="empty?-instance_method">
1068
+
1069
+ - (<tt>Boolean</tt>) <strong>empty?</strong>
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+ </h3><div class="docstring">
1076
+ <div class="discussion">
1077
+ <p>indicates whether the blobject contains any data</p>
1078
+
1079
+
1080
+ </div>
1081
+ </div>
1082
+ <div class="tags">
1083
+
1084
+ <p class="tag_title">Returns:</p>
1085
+ <ul class="return">
1086
+
1087
+ <li>
1088
+
1089
+
1090
+ <span class='type'>(<tt>Boolean</tt>)</span>
1091
+
1092
+
1093
+
1094
+ </li>
1095
+
1096
+ </ul>
1097
+
1098
+ </div><table class="source_code">
1099
+ <tr>
1100
+ <td>
1101
+ <pre class="lines">
1102
+
1103
+
1104
+ 31
1105
+ 32
1106
+ 33</pre>
1107
+ </td>
1108
+ <td>
1109
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 31</span>
1110
+
1111
+ <span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
1112
+ <span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1113
+ <span class='kw'>end</span></pre>
1114
+ </td>
1115
+ </tr>
1116
+ </table>
1046
1117
  </div>
1047
1118
 
1048
1119
  <div class="method_details ">
@@ -1056,8 +1127,7 @@ controllers: `render json: blobject`</p>
1056
1127
 
1057
1128
  </h3><div class="docstring">
1058
1129
  <div class="discussion">
1059
-
1060
- <p>freeze a Blobject to prevent it being modified</p>
1130
+ <p>freeze a Blobject to prevent it being modified</p>
1061
1131
 
1062
1132
 
1063
1133
  </div>
@@ -1071,23 +1141,63 @@ controllers: `render json: blobject`</p>
1071
1141
  <pre class="lines">
1072
1142
 
1073
1143
 
1074
- 133
1075
1144
  134
1076
1145
  135
1077
1146
  136
1078
1147
  137</pre>
1079
1148
  </td>
1080
1149
  <td>
1081
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 133</span>
1150
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 134</span>
1082
1151
 
1083
1152
  <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
1153
  <span class='ivar'>@hash</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
1086
1154
  <span class='kw'>super</span>
1087
1155
  <span class='kw'>end</span></pre>
1088
1156
  </td>
1089
1157
  </tr>
1090
1158
  </table>
1159
+ </div>
1160
+
1161
+ <div class="method_details ">
1162
+ <h3 class="signature " id="freeze_r-instance_method">
1163
+
1164
+ - (<tt>Object</tt>) <strong>freeze_r</strong>
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+ </h3><div class="docstring">
1171
+ <div class="discussion">
1172
+ <p>recursively freeze the Blobject include nest Blobjects in arrays</p>
1173
+
1174
+
1175
+ </div>
1176
+ </div>
1177
+ <div class="tags">
1178
+
1179
+
1180
+ </div><table class="source_code">
1181
+ <tr>
1182
+ <td>
1183
+ <pre class="lines">
1184
+
1185
+
1186
+ 140
1187
+ 141
1188
+ 142
1189
+ 143</pre>
1190
+ </td>
1191
+ <td>
1192
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 140</span>
1193
+
1194
+ <span class='kw'>def</span> <span class='id identifier rubyid_freeze_r'>freeze_r</span>
1195
+ <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='lparen'>(</span><span class='symbol'>:__freeze_r__</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
1196
+ <span class='id identifier rubyid_freeze'>freeze</span>
1197
+ <span class='kw'>end</span></pre>
1198
+ </td>
1199
+ </tr>
1200
+ </table>
1091
1201
  </div>
1092
1202
 
1093
1203
  <div class="method_details ">
@@ -1101,8 +1211,7 @@ controllers: `render json: blobject`</p>
1101
1211
 
1102
1212
  </h3><div class="docstring">
1103
1213
  <div class="discussion">
1104
-
1105
- <p>access the internal hash. be careful, this is <em>not</em> a copy</p>
1214
+ <p>access the internal hash. be careful, this is <em>not</em> a copy</p>
1106
1215
 
1107
1216
 
1108
1217
  </div>
@@ -1144,8 +1253,7 @@ controllers: `render json: blobject`</p>
1144
1253
 
1145
1254
  </h3><div class="docstring">
1146
1255
  <div class="discussion">
1147
-
1148
- <p>delegates to the internal Hash</p>
1256
+ <p>delegates to the internal Hash</p>
1149
1257
 
1150
1258
 
1151
1259
  </div>
@@ -1213,7 +1321,6 @@ controllers: `render json: blobject`</p>
1213
1321
  <pre class="lines">
1214
1322
 
1215
1323
 
1216
- 101
1217
1324
  102
1218
1325
  103
1219
1326
  104
@@ -1223,10 +1330,11 @@ controllers: `render json: blobject`</p>
1223
1330
  108
1224
1331
  109
1225
1332
  110
1226
- 111</pre>
1333
+ 111
1334
+ 112</pre>
1227
1335
  </td>
1228
1336
  <td>
1229
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 101</span>
1337
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 102</span>
1230
1338
 
1231
1339
  <span class='kw'>def</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span> <span class='id identifier rubyid_method'>method</span>
1232
1340
 
@@ -1255,8 +1363,7 @@ controllers: `render json: blobject`</p>
1255
1363
 
1256
1364
  </h3><div class="docstring">
1257
1365
  <div class="discussion">
1258
-
1259
- <p>creates a recursive copy of the internal hash</p>
1366
+ <p>creates a recursive copy of the internal hash</p>
1260
1367
 
1261
1368
 
1262
1369
  </div>
@@ -1285,7 +1392,7 @@ controllers: `render json: blobject`</p>
1285
1392
  <span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span>
1286
1393
 
1287
1394
  <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>
1395
+ <span class='ivar'>@hash</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_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
1289
1396
  <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
1397
  <span class='kw'>end</span>
1291
1398
  <span class='id identifier rubyid_h'>h</span>
@@ -1306,8 +1413,7 @@ controllers: `render json: blobject`</p>
1306
1413
 
1307
1414
  </h3><div class="docstring">
1308
1415
  <div class="discussion">
1309
-
1310
- <p>serialize the Blobject as a json string</p>
1416
+ <p>serialize the Blobject as a json string</p>
1311
1417
 
1312
1418
 
1313
1419
  </div>
@@ -1321,12 +1427,12 @@ controllers: `render json: blobject`</p>
1321
1427
  <pre class="lines">
1322
1428
 
1323
1429
 
1324
- 147
1325
- 148
1326
- 149</pre>
1430
+ 153
1431
+ 154
1432
+ 155</pre>
1327
1433
  </td>
1328
1434
  <td>
1329
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 147</span>
1435
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 153</span>
1330
1436
 
1331
1437
  <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
1438
  <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>
@@ -1347,8 +1453,7 @@ controllers: `render json: blobject`</p>
1347
1453
 
1348
1454
  </h3><div class="docstring">
1349
1455
  <div class="discussion">
1350
-
1351
- <p>serialize the Blobject as a yaml string</p>
1456
+ <p>serialize the Blobject as a yaml string</p>
1352
1457
 
1353
1458
 
1354
1459
  </div>
@@ -1362,13 +1467,13 @@ controllers: `render json: blobject`</p>
1362
1467
  <pre class="lines">
1363
1468
 
1364
1469
 
1365
- 152
1366
- 153
1367
- 154
1368
- 155</pre>
1470
+ 158
1471
+ 159
1472
+ 160
1473
+ 161</pre>
1369
1474
  </td>
1370
1475
  <td>
1371
- <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 152</span>
1476
+ <pre class="code"><span class="info file"># File 'lib/blobject.rb', line 158</span>
1372
1477
 
1373
1478
  <span class='kw'>def</span> <span class='id identifier rubyid_to_yaml'>to_yaml</span>
1374
1479
 
@@ -1384,7 +1489,7 @@ controllers: `render json: blobject`</p>
1384
1489
  </div>
1385
1490
 
1386
1491
  <div id="footer">
1387
- Generated on Thu Jun 7 00:25:32 2012 by
1492
+ Generated on Sun Jun 17 00:20:42 2012 by
1388
1493
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1389
1494
  0.8.1 (ruby-1.9.3).
1390
1495
  </div>