bitmask_attributes 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/CHANGELOG.rdoc +14 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -11
- data/{README.md → README.rdoc} +27 -28
- data/Rakefile +137 -0
- data/bitmask_attributes.gemspec +1 -3
- data/doc/apple-touch-icon.png +0 -0
- data/doc/classes/BitmaskAttributes.html +114 -0
- data/doc/classes/BitmaskAttributes/ClassMethods.html +205 -0
- data/doc/classes/BitmaskAttributes/Definition.html +690 -0
- data/doc/classes/BitmaskAttributes/ValueProxy.html +468 -0
- data/doc/created.rid +7 -0
- data/doc/css/github.css +129 -0
- data/doc/css/main.css +326 -0
- data/doc/css/panel.css +384 -0
- data/doc/css/reset.css +48 -0
- data/doc/favicon.ico +0 -0
- data/doc/files/CHANGELOG_rdoc.html +67 -0
- data/doc/files/README_rdoc.html +224 -0
- data/doc/files/lib/bitmask_attributes/definition_rb.html +83 -0
- data/doc/files/lib/bitmask_attributes/value_proxy_rb.html +83 -0
- data/doc/files/lib/bitmask_attributes/version_rb.html +78 -0
- data/doc/files/lib/bitmask_attributes_rb.html +93 -0
- data/doc/i/arrows.png +0 -0
- data/doc/i/results_bg.png +0 -0
- data/doc/i/tree_bg.png +0 -0
- data/doc/index.html +13 -0
- data/doc/js/highlight.pack.js +1 -0
- data/doc/js/jquery-1.3.2.min.js +19 -0
- data/doc/js/jquery-effect.js +593 -0
- data/doc/js/main.js +24 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searchdoc.js +442 -0
- data/doc/js/searcher.js +228 -0
- data/doc/panel/index.html +73 -0
- data/doc/panel/links.html +18 -0
- data/doc/panel/tree.js +1 -0
- data/lib/bitmask_attributes/definition.rb +4 -4
- data/lib/bitmask_attributes/version.rb +1 -1
- metadata +39 -6
@@ -0,0 +1,468 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<title>BitmaskAttributes::ValueProxy</title>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
8
|
+
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
|
9
|
+
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
|
10
|
+
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
|
11
|
+
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
|
16
|
+
</head>
|
17
|
+
|
18
|
+
<body>
|
19
|
+
<div class="banner">
|
20
|
+
|
21
|
+
<h1>
|
22
|
+
<span class="type">Class</span>
|
23
|
+
BitmaskAttributes::ValueProxy
|
24
|
+
|
25
|
+
<span class="parent"><
|
26
|
+
|
27
|
+
Array
|
28
|
+
|
29
|
+
</span>
|
30
|
+
|
31
|
+
</h1>
|
32
|
+
<ul class="files">
|
33
|
+
|
34
|
+
<li><a href="../../files/lib/bitmask_attributes/value_proxy_rb.html">lib/bitmask_attributes/value_proxy.rb</a></li>
|
35
|
+
|
36
|
+
</ul>
|
37
|
+
</div>
|
38
|
+
<div id="bodyContent">
|
39
|
+
<div id="content">
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
<!-- Method ref -->
|
55
|
+
<div class="sectiontitle">Methods</div>
|
56
|
+
<dl class="methods">
|
57
|
+
|
58
|
+
<dt>E</dt>
|
59
|
+
<dd>
|
60
|
+
<ul>
|
61
|
+
|
62
|
+
|
63
|
+
<li>
|
64
|
+
<a href="#method-i-extract_values">extract_values</a>
|
65
|
+
</li>
|
66
|
+
|
67
|
+
</ul>
|
68
|
+
</dd>
|
69
|
+
|
70
|
+
<dt>F</dt>
|
71
|
+
<dd>
|
72
|
+
<ul>
|
73
|
+
|
74
|
+
|
75
|
+
<li>
|
76
|
+
<a href="#method-i-find_mapping">find_mapping</a>
|
77
|
+
</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
</dd>
|
81
|
+
|
82
|
+
<dt>N</dt>
|
83
|
+
<dd>
|
84
|
+
<ul>
|
85
|
+
|
86
|
+
|
87
|
+
<li>
|
88
|
+
<a href="#method-c-new">new</a>
|
89
|
+
</li>
|
90
|
+
|
91
|
+
</ul>
|
92
|
+
</dd>
|
93
|
+
|
94
|
+
<dt>S</dt>
|
95
|
+
<dd>
|
96
|
+
<ul>
|
97
|
+
|
98
|
+
|
99
|
+
<li>
|
100
|
+
<a href="#method-i-serialize-21">serialize!</a>,
|
101
|
+
</li>
|
102
|
+
|
103
|
+
|
104
|
+
<li>
|
105
|
+
<a href="#method-i-symbolize-21">symbolize!</a>
|
106
|
+
</li>
|
107
|
+
|
108
|
+
</ul>
|
109
|
+
</dd>
|
110
|
+
|
111
|
+
<dt>T</dt>
|
112
|
+
<dd>
|
113
|
+
<ul>
|
114
|
+
|
115
|
+
|
116
|
+
<li>
|
117
|
+
<a href="#method-i-to_i">to_i</a>
|
118
|
+
</li>
|
119
|
+
|
120
|
+
</ul>
|
121
|
+
</dd>
|
122
|
+
|
123
|
+
<dt>U</dt>
|
124
|
+
<dd>
|
125
|
+
<ul>
|
126
|
+
|
127
|
+
|
128
|
+
<li>
|
129
|
+
<a href="#method-i-updated-21">updated!</a>
|
130
|
+
</li>
|
131
|
+
|
132
|
+
</ul>
|
133
|
+
</dd>
|
134
|
+
|
135
|
+
<dt>V</dt>
|
136
|
+
<dd>
|
137
|
+
<ul>
|
138
|
+
|
139
|
+
|
140
|
+
<li>
|
141
|
+
<a href="#method-i-validate-21">validate!</a>
|
142
|
+
</li>
|
143
|
+
|
144
|
+
</ul>
|
145
|
+
</dd>
|
146
|
+
|
147
|
+
</dl>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
<!-- Methods -->
|
167
|
+
|
168
|
+
<div class="sectiontitle">Class Public methods</div>
|
169
|
+
|
170
|
+
<div class="method">
|
171
|
+
<div class="title method-title" id="method-c-new">
|
172
|
+
|
173
|
+
<a name="method-c-new"></a><b>new</b>(record, attribute, &extension)
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
|
178
|
+
<div class="description">
|
179
|
+
|
180
|
+
</div>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
<div class="sourcecode">
|
188
|
+
|
189
|
+
<p class="source-link">
|
190
|
+
Source:
|
191
|
+
<a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
|
192
|
+
|
193
|
+
</p>
|
194
|
+
<div id="method-c-new_source" class="dyn-source">
|
195
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 4</span>
|
196
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">record</span>, <span class="ruby-identifier">attribute</span>, &<span class="ruby-identifier">extension</span>)
|
197
|
+
<span class="ruby-ivar">@record</span> = <span class="ruby-identifier">record</span>
|
198
|
+
<span class="ruby-ivar">@attribute</span> = <span class="ruby-identifier">attribute</span>
|
199
|
+
<span class="ruby-identifier">find_mapping</span>
|
200
|
+
<span class="ruby-identifier">instance_eval</span>(&<span class="ruby-identifier">extension</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">extension</span>
|
201
|
+
<span class="ruby-keyword">super</span>(<span class="ruby-identifier">extract_values</span>)
|
202
|
+
<span class="ruby-keyword">end</span></pre>
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
</div>
|
207
|
+
|
208
|
+
<div class="sectiontitle">Instance Public methods</div>
|
209
|
+
|
210
|
+
<div class="method">
|
211
|
+
<div class="title method-title" id="method-i-to_i">
|
212
|
+
|
213
|
+
<a name="method-i-to_i"></a><b>to_i</b>()
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
|
218
|
+
<div class="description">
|
219
|
+
|
220
|
+
</div>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
<div class="sourcecode">
|
228
|
+
|
229
|
+
<p class="source-link">
|
230
|
+
Source:
|
231
|
+
<a href="javascript:toggleSource('method-i-to_i_source')" id="l_method-i-to_i_source">show</a>
|
232
|
+
|
233
|
+
</p>
|
234
|
+
<div id="method-i-to_i_source" class="dyn-source">
|
235
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 27</span>
|
236
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_i</span>
|
237
|
+
<span class="ruby-identifier">inject</span>(<span class="ruby-number">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">memo</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">memo</span> <span class="ruby-operator">|</span> <span class="ruby-ivar">@mapping</span>[<span class="ruby-identifier">value</span>] }
|
238
|
+
<span class="ruby-keyword">end</span></pre>
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div class="sectiontitle">Instance Private methods</div>
|
245
|
+
|
246
|
+
<div class="method">
|
247
|
+
<div class="title method-title" id="method-i-extract_values">
|
248
|
+
|
249
|
+
<a name="method-i-extract_values"></a><b>extract_values</b>()
|
250
|
+
|
251
|
+
</div>
|
252
|
+
|
253
|
+
|
254
|
+
<div class="description">
|
255
|
+
|
256
|
+
</div>
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<div class="sourcecode">
|
264
|
+
|
265
|
+
<p class="source-link">
|
266
|
+
Source:
|
267
|
+
<a href="javascript:toggleSource('method-i-extract_values_source')" id="l_method-i-extract_values_source">show</a>
|
268
|
+
|
269
|
+
</p>
|
270
|
+
<div id="method-i-extract_values_source" class="dyn-source">
|
271
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 58</span>
|
272
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">extract_values</span>
|
273
|
+
<span class="ruby-identifier">stored</span> = [<span class="ruby-ivar">@record</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:read_attribute</span>, <span class="ruby-ivar">@attribute</span>) <span class="ruby-operator">||</span> <span class="ruby-number">0</span>, <span class="ruby-number">0</span>].<span class="ruby-identifier">max</span>
|
274
|
+
<span class="ruby-ivar">@mapping</span>.<span class="ruby-identifier">inject</span>([]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">values</span>, (<span class="ruby-identifier">value</span>, <span class="ruby-identifier">bitmask</span>)<span class="ruby-operator">|</span>
|
275
|
+
<span class="ruby-identifier">values</span>.<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span>
|
276
|
+
<span class="ruby-identifier">values</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">if</span> (<span class="ruby-identifier">stored</span> & <span class="ruby-identifier">bitmask</span> <span class="ruby-operator">></span> <span class="ruby-number">0</span>)
|
277
|
+
<span class="ruby-keyword">end</span>
|
278
|
+
<span class="ruby-keyword">end</span>
|
279
|
+
<span class="ruby-keyword">end</span></pre>
|
280
|
+
</div>
|
281
|
+
</div>
|
282
|
+
|
283
|
+
</div>
|
284
|
+
|
285
|
+
<div class="method">
|
286
|
+
<div class="title method-title" id="method-i-find_mapping">
|
287
|
+
|
288
|
+
<a name="method-i-find_mapping"></a><b>find_mapping</b>()
|
289
|
+
|
290
|
+
</div>
|
291
|
+
|
292
|
+
|
293
|
+
<div class="description">
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
<div class="sourcecode">
|
303
|
+
|
304
|
+
<p class="source-link">
|
305
|
+
Source:
|
306
|
+
<a href="javascript:toggleSource('method-i-find_mapping_source')" id="l_method-i-find_mapping_source">show</a>
|
307
|
+
|
308
|
+
</p>
|
309
|
+
<div id="method-i-find_mapping_source" class="dyn-source">
|
310
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 67</span>
|
311
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">find_mapping</span>
|
312
|
+
<span class="ruby-keyword">unless</span> (<span class="ruby-ivar">@mapping</span> = <span class="ruby-ivar">@record</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">bitmasks</span>[<span class="ruby-ivar">@attribute</span>])
|
313
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Could not find mapping for bitmask attribute :#{@attribute}"</span>
|
314
|
+
<span class="ruby-keyword">end</span>
|
315
|
+
<span class="ruby-keyword">end</span></pre>
|
316
|
+
</div>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
</div>
|
320
|
+
|
321
|
+
<div class="method">
|
322
|
+
<div class="title method-title" id="method-i-serialize-21">
|
323
|
+
|
324
|
+
<a name="method-i-serialize-21"></a><b>serialize!</b>()
|
325
|
+
|
326
|
+
</div>
|
327
|
+
|
328
|
+
|
329
|
+
<div class="description">
|
330
|
+
|
331
|
+
</div>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
<div class="sourcecode">
|
339
|
+
|
340
|
+
<p class="source-link">
|
341
|
+
Source:
|
342
|
+
<a href="javascript:toggleSource('method-i-serialize-21_source')" id="l_method-i-serialize-21_source">show</a>
|
343
|
+
|
344
|
+
</p>
|
345
|
+
<div id="method-i-serialize-21_source" class="dyn-source">
|
346
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 54</span>
|
347
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">serialize!</span>
|
348
|
+
<span class="ruby-ivar">@record</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:write_attribute</span>, <span class="ruby-ivar">@attribute</span>, <span class="ruby-identifier">to_i</span>)
|
349
|
+
<span class="ruby-keyword">end</span></pre>
|
350
|
+
</div>
|
351
|
+
</div>
|
352
|
+
|
353
|
+
</div>
|
354
|
+
|
355
|
+
<div class="method">
|
356
|
+
<div class="title method-title" id="method-i-symbolize-21">
|
357
|
+
|
358
|
+
<a name="method-i-symbolize-21"></a><b>symbolize!</b>()
|
359
|
+
|
360
|
+
</div>
|
361
|
+
|
362
|
+
|
363
|
+
<div class="description">
|
364
|
+
|
365
|
+
</div>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
<div class="sourcecode">
|
373
|
+
|
374
|
+
<p class="source-link">
|
375
|
+
Source:
|
376
|
+
<a href="javascript:toggleSource('method-i-symbolize-21_source')" id="l_method-i-symbolize-21_source">show</a>
|
377
|
+
|
378
|
+
</p>
|
379
|
+
<div id="method-i-symbolize-21_source" class="dyn-source">
|
380
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 43</span>
|
381
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">symbolize!</span>
|
382
|
+
<span class="ruby-identifier">orig_replace</span>(<span class="ruby-identifier">map</span>(&<span class="ruby-value">:to_sym</span>))
|
383
|
+
<span class="ruby-keyword">end</span></pre>
|
384
|
+
</div>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
<div class="method">
|
390
|
+
<div class="title method-title" id="method-i-updated-21">
|
391
|
+
|
392
|
+
<a name="method-i-updated-21"></a><b>updated!</b>()
|
393
|
+
|
394
|
+
</div>
|
395
|
+
|
396
|
+
|
397
|
+
<div class="description">
|
398
|
+
|
399
|
+
</div>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
<div class="sourcecode">
|
407
|
+
|
408
|
+
<p class="source-link">
|
409
|
+
Source:
|
410
|
+
<a href="javascript:toggleSource('method-i-updated-21_source')" id="l_method-i-updated-21_source">show</a>
|
411
|
+
|
412
|
+
</p>
|
413
|
+
<div id="method-i-updated-21_source" class="dyn-source">
|
414
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 47</span>
|
415
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">updated!</span>
|
416
|
+
<span class="ruby-identifier">validate!</span>
|
417
|
+
<span class="ruby-identifier">symbolize!</span>
|
418
|
+
<span class="ruby-identifier">uniq!</span>
|
419
|
+
<span class="ruby-identifier">serialize!</span>
|
420
|
+
<span class="ruby-keyword">end</span></pre>
|
421
|
+
</div>
|
422
|
+
</div>
|
423
|
+
|
424
|
+
</div>
|
425
|
+
|
426
|
+
<div class="method">
|
427
|
+
<div class="title method-title" id="method-i-validate-21">
|
428
|
+
|
429
|
+
<a name="method-i-validate-21"></a><b>validate!</b>()
|
430
|
+
|
431
|
+
</div>
|
432
|
+
|
433
|
+
|
434
|
+
<div class="description">
|
435
|
+
|
436
|
+
</div>
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
<div class="sourcecode">
|
444
|
+
|
445
|
+
<p class="source-link">
|
446
|
+
Source:
|
447
|
+
<a href="javascript:toggleSource('method-i-validate-21_source')" id="l_method-i-validate-21_source">show</a>
|
448
|
+
|
449
|
+
</p>
|
450
|
+
<div id="method-i-validate-21_source" class="dyn-source">
|
451
|
+
<pre><span class="ruby-comment"># File lib/bitmask_attributes/value_proxy.rb, line 33</span>
|
452
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">validate!</span>
|
453
|
+
<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
454
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@mapping</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">value</span>
|
455
|
+
<span class="ruby-keyword">true</span>
|
456
|
+
<span class="ruby-keyword">else</span>
|
457
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Unsupported value for `#{@attribute}': #{value.inspect}"</span>
|
458
|
+
<span class="ruby-keyword">end</span>
|
459
|
+
<span class="ruby-keyword">end</span>
|
460
|
+
<span class="ruby-keyword">end</span></pre>
|
461
|
+
</div>
|
462
|
+
</div>
|
463
|
+
|
464
|
+
</div>
|
465
|
+
</div>
|
466
|
+
</div>
|
467
|
+
</body>
|
468
|
+
</html>
|