whyvalidationssuckin96 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.md +121 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/doc/ActiveRecord/RecordInvalid.html +258 -0
- data/doc/ActiveRecord.html +93 -0
- data/doc/FalseClass.html +87 -0
- data/doc/NilClass.html +87 -0
- data/doc/Numeric.html +87 -0
- data/doc/Object.html +79 -0
- data/doc/String.html +87 -0
- data/doc/TrueClass.html +87 -0
- data/doc/WhyValidationsSuckIn96/ActiveRecord/InstanceMethods.html +156 -0
- data/doc/WhyValidationsSuckIn96/ActiveRecord.html +192 -0
- data/doc/WhyValidationsSuckIn96/AttributeBasedValidation.html +464 -0
- data/doc/WhyValidationsSuckIn96/SkippableValidation.html +194 -0
- data/doc/WhyValidationsSuckIn96/ValidatesAcceptance.html +254 -0
- data/doc/WhyValidationsSuckIn96/ValidatesAssociated.html +250 -0
- data/doc/WhyValidationsSuckIn96/ValidatesConfirmation.html +251 -0
- data/doc/WhyValidationsSuckIn96/ValidatesExclusion.html +388 -0
- data/doc/WhyValidationsSuckIn96/ValidatesFormat.html +387 -0
- data/doc/WhyValidationsSuckIn96/ValidatesInclusion.html +388 -0
- data/doc/WhyValidationsSuckIn96/ValidatesLength.html +469 -0
- data/doc/WhyValidationsSuckIn96/ValidatesNumericality.html +267 -0
- data/doc/WhyValidationsSuckIn96/ValidatesPresence.html +244 -0
- data/doc/WhyValidationsSuckIn96/ValidatesUniqueness.html +289 -0
- data/doc/WhyValidationsSuckIn96/Validation.html +934 -0
- data/doc/WhyValidationsSuckIn96/ValidationBuilder.html +391 -0
- data/doc/WhyValidationsSuckIn96/ValidationSupport/ClassMethods.html +249 -0
- data/doc/WhyValidationsSuckIn96/ValidationSupport/InstanceMethods.html +484 -0
- data/doc/WhyValidationsSuckIn96/ValidationSupport.html +168 -0
- data/doc/WhyValidationsSuckIn96.html +97 -0
- data/doc/_index.html +346 -0
- data/doc/class_list.html +293 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +23 -0
- data/doc/css/style.css +263 -0
- data/doc/file.README.html +173 -0
- data/doc/file_list.html +29 -0
- data/doc/index.html +173 -0
- data/doc/js/app.js +91 -0
- data/doc/js/full_list.js +39 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +462 -0
- data/doc/top-level-namespace.html +81 -0
- data/lib/whyvalidationssuckin96/attribute_based_validation.rb +46 -0
- data/lib/whyvalidationssuckin96/constants.rb +3 -0
- data/lib/whyvalidationssuckin96/ext/blank.rb +47 -0
- data/lib/whyvalidationssuckin96/macros/validates_acceptance.rb +36 -0
- data/lib/whyvalidationssuckin96/macros/validates_associated.rb +33 -0
- data/lib/whyvalidationssuckin96/macros/validates_confirmation.rb +40 -0
- data/lib/whyvalidationssuckin96/macros/validates_exclusion.rb +38 -0
- data/lib/whyvalidationssuckin96/macros/validates_format.rb +38 -0
- data/lib/whyvalidationssuckin96/macros/validates_inclusion.rb +38 -0
- data/lib/whyvalidationssuckin96/macros/validates_length.rb +98 -0
- data/lib/whyvalidationssuckin96/macros/validates_numericality.rb +56 -0
- data/lib/whyvalidationssuckin96/macros/validates_presence.rb +30 -0
- data/lib/whyvalidationssuckin96/macros.rb +9 -0
- data/lib/whyvalidationssuckin96/rails/active_record.rb +94 -0
- data/lib/whyvalidationssuckin96/rails/macros/validates_uniqueness.rb +87 -0
- data/lib/whyvalidationssuckin96/rails/macros.rb +1 -0
- data/lib/whyvalidationssuckin96/skippable_validation.rb +59 -0
- data/lib/whyvalidationssuckin96/validation.rb +88 -0
- data/lib/whyvalidationssuckin96/validation_builder.rb +56 -0
- data/lib/whyvalidationssuckin96/validation_support.rb +74 -0
- data/lib/whyvalidationssuckin96.rb +4 -0
- data/test/attribute_based_validation_test.rb +58 -0
- data/test/macros/validates_acceptance_test.rb +64 -0
- data/test/macros/validates_associated_test.rb +60 -0
- data/test/macros/validates_confirmation_test.rb +63 -0
- data/test/macros/validates_exclusion_test.rb +37 -0
- data/test/macros/validates_format_test.rb +43 -0
- data/test/macros/validates_inclusion_test.rb +37 -0
- data/test/macros/validates_length_test.rb +179 -0
- data/test/macros/validates_numericality_test.rb +129 -0
- data/test/macros/validates_presence_test.rb +31 -0
- data/test/rails/active_record_test.rb +187 -0
- data/test/rails/active_record_test_helper.rb +90 -0
- data/test/rails/macros/validates_uniqueness_test.rb +153 -0
- data/test/skippable_validation_test.rb +102 -0
- data/test/teststrap.rb +4 -0
- data/test/validation_builder_test.rb +62 -0
- data/test/validation_support_test.rb +209 -0
- data/test/validation_test.rb +101 -0
- data/whyvalidationssuckin96.gemspec +153 -0
- metadata +189 -0
@@ -0,0 +1,934 @@
|
|
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 name="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title>Class: WhyValidationsSuckIn96::Validation</title>
|
7
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '..';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="header">
|
20
|
+
<div id="menu">
|
21
|
+
|
22
|
+
<a href="../_index.html">Index (V)</a> »
|
23
|
+
<a href="../WhyValidationsSuckIn96.html" title="WhyValidationsSuckIn96">WhyValidationsSuckIn96</a>
|
24
|
+
»
|
25
|
+
<span class="title">Validation</span>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="search">
|
30
|
+
<a id="class_list_link" href="#">Namespace List</a>
|
31
|
+
<a id="method_list_link" href="#">Method List</a>
|
32
|
+
<a id ="file_list_link" href="#">File List</a>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="clear"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<iframe id="search_frame"></iframe>
|
39
|
+
|
40
|
+
<div id="content"><h1>Class: WhyValidationsSuckIn96::Validation
|
41
|
+
|
42
|
+
|
43
|
+
</h1>
|
44
|
+
|
45
|
+
<dl class="box">
|
46
|
+
|
47
|
+
<dt class="r1">Inherits:</dt>
|
48
|
+
<dd class="r1">
|
49
|
+
<span class="inheritName"><a href="../Object.html" title="Object">Object</a></span>
|
50
|
+
|
51
|
+
<ul class="fullTree">
|
52
|
+
<li><a href="../Object.html" title="Object">Object</a></li>
|
53
|
+
|
54
|
+
<li class="next">WhyValidationsSuckIn96::Validation</li>
|
55
|
+
|
56
|
+
</ul>
|
57
|
+
<a href="#" class="inheritanceTree">show all</a>
|
58
|
+
|
59
|
+
</dd>
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
<dt class="r2 last">Defined in:</dt>
|
69
|
+
<dd class="r2 last">lib/whyvalidationssuckin96/validation.rb</dd>
|
70
|
+
|
71
|
+
</dl>
|
72
|
+
<div class="clear"></div>
|
73
|
+
|
74
|
+
<h2>Overview</h2><div class="docstring">
|
75
|
+
<div class="discussion">
|
76
|
+
<p>
|
77
|
+
Base class to use when implementing validations.
|
78
|
+
</p>
|
79
|
+
|
80
|
+
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
<div class="tags">
|
84
|
+
|
85
|
+
</div>
|
86
|
+
<h2>Constant Summary</h2>
|
87
|
+
|
88
|
+
<dl class="constants">
|
89
|
+
|
90
|
+
<dt id="DefaultOptions-constant ">DefaultOptions =
|
91
|
+
<span class="summary_desc">
|
92
|
+
A hash of default options for the validation to use.
|
93
|
+
|
94
|
+
</span>
|
95
|
+
</dt>
|
96
|
+
<dd><pre class="code"><span class='lbrace token'>{</span><span class='rbrace token'>}</span>
|
97
|
+
</pre></dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<h2>Class Attribute Summary</h2>
|
104
|
+
<ul class="summary">
|
105
|
+
|
106
|
+
<li class="public ">
|
107
|
+
<span class="summary_signature">
|
108
|
+
|
109
|
+
<a href="#name-class_method" title="name (class method)">+ (Object) <strong>name</strong> </a>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
</span>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<span class="summary_desc">
|
125
|
+
Returns the value of attribute name.
|
126
|
+
|
127
|
+
</span>
|
128
|
+
|
129
|
+
</li>
|
130
|
+
|
131
|
+
|
132
|
+
</ul>
|
133
|
+
|
134
|
+
<h2>Instance Attribute Summary</h2>
|
135
|
+
<ul class="summary">
|
136
|
+
|
137
|
+
<li class="public ">
|
138
|
+
<span class="summary_signature">
|
139
|
+
|
140
|
+
<a href="#options-instance_method" title="#options (instance method)">- (Object) <strong>options</strong> </a>
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
</span>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<span class="summary_desc">
|
156
|
+
The options the validation was initialized with.
|
157
|
+
|
158
|
+
</span>
|
159
|
+
|
160
|
+
</li>
|
161
|
+
|
162
|
+
|
163
|
+
<li class="public ">
|
164
|
+
<span class="summary_signature">
|
165
|
+
|
166
|
+
<a href="#validatable-instance_method" title="#validatable (instance method)">- (Object) <strong>validatable</strong> </a>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</span>
|
171
|
+
|
172
|
+
|
173
|
+
<span class="note title readonly">readonly</span>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<span class="summary_desc">
|
182
|
+
The object the validation is validating.
|
183
|
+
|
184
|
+
</span>
|
185
|
+
|
186
|
+
</li>
|
187
|
+
|
188
|
+
|
189
|
+
</ul>
|
190
|
+
|
191
|
+
|
192
|
+
<h2>Class Method Summary</h2>
|
193
|
+
|
194
|
+
<ul class="summary">
|
195
|
+
|
196
|
+
<li class="public ">
|
197
|
+
<span class="summary_signature">
|
198
|
+
|
199
|
+
<a href="#new_subclass-class_method" title="new_subclass (class method)">+ (Object) <strong>new_subclass</strong>(name, def_block) </a>
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
</span>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<span class="summary_desc">
|
212
|
+
Creates a new subclass of this class, used when defining custom validations
|
213
|
+
with a block.
|
214
|
+
|
215
|
+
</span>
|
216
|
+
|
217
|
+
</li>
|
218
|
+
|
219
|
+
|
220
|
+
</ul>
|
221
|
+
|
222
|
+
<h2>Instance Method Summary</h2>
|
223
|
+
|
224
|
+
<ul class="summary">
|
225
|
+
|
226
|
+
<li class="public ">
|
227
|
+
<span class="summary_signature">
|
228
|
+
|
229
|
+
<a href="#failed%3F-instance_method" title="#failed? (instance method)">- (true, false) <strong>failed?</strong> </a>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
</span>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<span class="summary_desc">
|
242
|
+
Has this validation failed?.
|
243
|
+
|
244
|
+
</span>
|
245
|
+
|
246
|
+
</li>
|
247
|
+
|
248
|
+
|
249
|
+
<li class="public ">
|
250
|
+
<span class="summary_signature">
|
251
|
+
|
252
|
+
<a href="#has_run%3F-instance_method" title="#has_run? (instance method)">- (true, false) <strong>has_run?</strong> </a>
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
</span>
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
<span class="summary_desc">
|
265
|
+
Has this validation run?.
|
266
|
+
|
267
|
+
</span>
|
268
|
+
|
269
|
+
</li>
|
270
|
+
|
271
|
+
|
272
|
+
<li class="public ">
|
273
|
+
<span class="summary_signature">
|
274
|
+
|
275
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Validation) <strong>initialize</strong>(validatable, options = {}) </a>
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
</span>
|
280
|
+
|
281
|
+
<span class="note title constructor">constructor</span>
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
<span class="summary_desc">
|
290
|
+
A new instance of Validation.
|
291
|
+
|
292
|
+
</span>
|
293
|
+
|
294
|
+
</li>
|
295
|
+
|
296
|
+
|
297
|
+
<li class="public ">
|
298
|
+
<span class="summary_signature">
|
299
|
+
|
300
|
+
<a href="#message-instance_method" title="#message (instance method)">- (Object) <strong>message</strong> </a>
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
</span>
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
<span class="summary_desc">
|
313
|
+
The failure message for this validation.
|
314
|
+
|
315
|
+
</span>
|
316
|
+
|
317
|
+
</li>
|
318
|
+
|
319
|
+
|
320
|
+
<li class="public ">
|
321
|
+
<span class="summary_signature">
|
322
|
+
|
323
|
+
<a href="#passed%3F-instance_method" title="#passed? (instance method)">- (true, false) <strong>passed?</strong> </a>
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
</span>
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
<span class="summary_desc">
|
336
|
+
Has this validation passed?.
|
337
|
+
|
338
|
+
</span>
|
339
|
+
|
340
|
+
</li>
|
341
|
+
|
342
|
+
|
343
|
+
<li class="public ">
|
344
|
+
<span class="summary_signature">
|
345
|
+
|
346
|
+
<a href="#validates%3F-instance_method" title="#validates? (instance method)">- (true, ...) <strong>validates?</strong> </a>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
</span>
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
<span class="summary_desc">
|
359
|
+
Performs the validation, returning true or false if the validation passes
|
360
|
+
or fails, or nil if the validation will not run.
|
361
|
+
|
362
|
+
</span>
|
363
|
+
|
364
|
+
</li>
|
365
|
+
|
366
|
+
|
367
|
+
</ul>
|
368
|
+
<div id="constructor_details" class="method_details_list">
|
369
|
+
<h2>Constructor Details</h2>
|
370
|
+
|
371
|
+
<div class="method_details first">
|
372
|
+
<p class="signature first" id="initialize-instance_method">
|
373
|
+
|
374
|
+
- (<tt><a href="" title="Validation">Validation</a></tt>) <strong>initialize</strong>(validatable, options = {})
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
</p><div class="docstring">
|
379
|
+
<div class="discussion">
|
380
|
+
<p>
|
381
|
+
A new instance of Validation
|
382
|
+
</p>
|
383
|
+
|
384
|
+
|
385
|
+
</div>
|
386
|
+
</div>
|
387
|
+
<div class="tags">
|
388
|
+
<h3>Parameters:</h3>
|
389
|
+
<ul class="param">
|
390
|
+
|
391
|
+
<li>
|
392
|
+
|
393
|
+
<span class='type'>(<tt><a href="../Object.html" title="Object">Object</a></tt>)</span>
|
394
|
+
|
395
|
+
|
396
|
+
<span class='name'>validatable</span>
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
—
|
401
|
+
|
402
|
+
An object to be validated
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
</li>
|
407
|
+
|
408
|
+
<li>
|
409
|
+
|
410
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
411
|
+
|
412
|
+
|
413
|
+
<span class='name'>options</span>
|
414
|
+
|
415
|
+
|
416
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
417
|
+
|
418
|
+
|
419
|
+
—
|
420
|
+
|
421
|
+
The options to set up the validation with
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
</li>
|
426
|
+
|
427
|
+
</ul>
|
428
|
+
|
429
|
+
</div><table class="source_code">
|
430
|
+
<tr>
|
431
|
+
<td>
|
432
|
+
<pre class="lines">
|
433
|
+
|
434
|
+
|
435
|
+
21
|
436
|
+
22
|
437
|
+
23
|
438
|
+
24</pre>
|
439
|
+
</td>
|
440
|
+
<td>
|
441
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 21</span>
|
442
|
+
|
443
|
+
<span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='validatable identifier id'>validatable</span><span class='comma token'>,</span> <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
444
|
+
<span class='@validatable ivar id'>@validatable</span> <span class='assign token'>=</span> <span class='validatable identifier id'>validatable</span>
|
445
|
+
<span class='@options ivar id'>@options</span> <span class='assign token'>=</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='class identifier id'>class</span><span class='colon2 op'>::</span><span class='DefaultOptions constant id'>DefaultOptions</span><span class='dot token'>.</span><span class='merge identifier id'>merge</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
446
|
+
<span class='end end kw'>end</span>
|
447
|
+
</pre>
|
448
|
+
</td>
|
449
|
+
</tr>
|
450
|
+
</table>
|
451
|
+
</div>
|
452
|
+
|
453
|
+
</div>
|
454
|
+
|
455
|
+
<div id="class_attr_details" class="attr_details">
|
456
|
+
<h2>Class Attribute Details</h2>
|
457
|
+
|
458
|
+
|
459
|
+
<span id="name=-class_method"></span>
|
460
|
+
<span id="name-class_method"></span>
|
461
|
+
<div class="method_details first">
|
462
|
+
<p class="signature first" id="name-class_method">
|
463
|
+
|
464
|
+
+ (<tt><a href="../Object.html" title="Object">Object</a></tt>) <strong>name</strong>
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
</p><div class="docstring">
|
469
|
+
<div class="discussion">
|
470
|
+
<p>
|
471
|
+
Returns the value of attribute name
|
472
|
+
</p>
|
473
|
+
|
474
|
+
|
475
|
+
</div>
|
476
|
+
</div>
|
477
|
+
<div class="tags">
|
478
|
+
|
479
|
+
</div><table class="source_code">
|
480
|
+
<tr>
|
481
|
+
<td>
|
482
|
+
<pre class="lines">
|
483
|
+
|
484
|
+
|
485
|
+
16
|
486
|
+
17
|
487
|
+
18</pre>
|
488
|
+
</td>
|
489
|
+
<td>
|
490
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 16</span>
|
491
|
+
|
492
|
+
<span class='def def kw'>def</span> <span class='name identifier id'>name</span>
|
493
|
+
<span class='@name ivar id'>@name</span>
|
494
|
+
<span class='end end kw'>end</span>
|
495
|
+
</pre>
|
496
|
+
</td>
|
497
|
+
</tr>
|
498
|
+
</table>
|
499
|
+
</div>
|
500
|
+
|
501
|
+
</div>
|
502
|
+
|
503
|
+
<div id="instance_attr_details" class="attr_details">
|
504
|
+
<h2>Instance Attribute Details</h2>
|
505
|
+
|
506
|
+
|
507
|
+
<span id="options=-instance_method"></span>
|
508
|
+
<span id="options-instance_method"></span>
|
509
|
+
<div class="method_details first">
|
510
|
+
<p class="signature first" id="options-instance_method">
|
511
|
+
|
512
|
+
- (<tt><a href="../Object.html" title="Object">Object</a></tt>) <strong>options</strong>
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
</p><div class="docstring">
|
517
|
+
<div class="discussion">
|
518
|
+
<p>
|
519
|
+
The options the validation was initialized with
|
520
|
+
</p>
|
521
|
+
|
522
|
+
|
523
|
+
</div>
|
524
|
+
</div>
|
525
|
+
<div class="tags">
|
526
|
+
|
527
|
+
</div><table class="source_code">
|
528
|
+
<tr>
|
529
|
+
<td>
|
530
|
+
<pre class="lines">
|
531
|
+
|
532
|
+
|
533
|
+
10
|
534
|
+
11
|
535
|
+
12</pre>
|
536
|
+
</td>
|
537
|
+
<td>
|
538
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 10</span>
|
539
|
+
|
540
|
+
<span class='def def kw'>def</span> <span class='options identifier id'>options</span>
|
541
|
+
<span class='@options ivar id'>@options</span>
|
542
|
+
<span class='end end kw'>end</span>
|
543
|
+
</pre>
|
544
|
+
</td>
|
545
|
+
</tr>
|
546
|
+
</table>
|
547
|
+
</div>
|
548
|
+
|
549
|
+
|
550
|
+
<span id=""></span>
|
551
|
+
<span id="validatable-instance_method"></span>
|
552
|
+
<div class="method_details ">
|
553
|
+
<p class="signature " id="validatable-instance_method">
|
554
|
+
|
555
|
+
- (<tt><a href="../Object.html" title="Object">Object</a></tt>) <strong>validatable</strong> <span class="extras">(readonly)</span>
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
</p><div class="docstring">
|
560
|
+
<div class="discussion">
|
561
|
+
<p>
|
562
|
+
The object the validation is validating
|
563
|
+
</p>
|
564
|
+
|
565
|
+
|
566
|
+
</div>
|
567
|
+
</div>
|
568
|
+
<div class="tags">
|
569
|
+
|
570
|
+
</div><table class="source_code">
|
571
|
+
<tr>
|
572
|
+
<td>
|
573
|
+
<pre class="lines">
|
574
|
+
|
575
|
+
|
576
|
+
13
|
577
|
+
14
|
578
|
+
15</pre>
|
579
|
+
</td>
|
580
|
+
<td>
|
581
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 13</span>
|
582
|
+
|
583
|
+
<span class='def def kw'>def</span> <span class='validatable identifier id'>validatable</span>
|
584
|
+
<span class='@validatable ivar id'>@validatable</span>
|
585
|
+
<span class='end end kw'>end</span>
|
586
|
+
</pre>
|
587
|
+
</td>
|
588
|
+
</tr>
|
589
|
+
</table>
|
590
|
+
</div>
|
591
|
+
|
592
|
+
</div>
|
593
|
+
|
594
|
+
|
595
|
+
<div id="class_method_details" class="method_details_list">
|
596
|
+
<h2>Class Method Details</h2>
|
597
|
+
|
598
|
+
|
599
|
+
<div class="method_details first">
|
600
|
+
<p class="signature first" id="new_subclass-class_method">
|
601
|
+
|
602
|
+
+ (<tt><a href="../Object.html" title="Object">Object</a></tt>) <strong>new_subclass</strong>(name, def_block)
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
</p><div class="docstring">
|
607
|
+
<div class="discussion">
|
608
|
+
<p>
|
609
|
+
Creates a new subclass of this class, used when defining custom validations
|
610
|
+
with a block
|
611
|
+
</p>
|
612
|
+
|
613
|
+
|
614
|
+
</div>
|
615
|
+
</div>
|
616
|
+
<div class="tags">
|
617
|
+
|
618
|
+
</div><table class="source_code">
|
619
|
+
<tr>
|
620
|
+
<td>
|
621
|
+
<pre class="lines">
|
622
|
+
|
623
|
+
|
624
|
+
27
|
625
|
+
28
|
626
|
+
29
|
627
|
+
30
|
628
|
+
31
|
629
|
+
32
|
630
|
+
33
|
631
|
+
34
|
632
|
+
35
|
633
|
+
36
|
634
|
+
37</pre>
|
635
|
+
</td>
|
636
|
+
<td>
|
637
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 27</span>
|
638
|
+
|
639
|
+
<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='new_subclass identifier id'>new_subclass</span><span class='lparen token'>(</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='def_block identifier id'>def_block</span><span class='rparen token'>)</span>
|
640
|
+
<span class='Class constant id'>Class</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='rparen token'>)</span> <span class='do do kw'>do</span>
|
641
|
+
<span class='self self kw'>self</span><span class='dot token'>.</span><span class='name identifier id'>name</span> <span class='assign token'>=</span> <span class='name identifier id'>name</span><span class='dot token'>.</span><span class='to_sym identifier id'>to_sym</span>
|
642
|
+
<span class='define_method identifier id'>define_method</span><span class='lparen token'>(</span><span class='symbol val'>:validate</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='def_block identifier id'>def_block</span><span class='rparen token'>)</span>
|
643
|
+
<span class='private identifier id'>private</span> <span class='symbol val'>:validate</span>
|
644
|
+
|
645
|
+
<span class='def def kw'>def</span> <span class='inspect identifier id'>inspect</span>
|
646
|
+
<span class='dstring node'>"#<WhyValidationsSuckIn96::Validation subclass for validating '#{self.class.name}'> #{super}"</span>
|
647
|
+
<span class='end end kw'>end</span>
|
648
|
+
<span class='end end kw'>end</span>
|
649
|
+
<span class='end end kw'>end</span>
|
650
|
+
</pre>
|
651
|
+
</td>
|
652
|
+
</tr>
|
653
|
+
</table>
|
654
|
+
</div>
|
655
|
+
|
656
|
+
</div>
|
657
|
+
|
658
|
+
<div id="instance_method_details" class="method_details_list">
|
659
|
+
<h2>Instance Method Details</h2>
|
660
|
+
|
661
|
+
|
662
|
+
<div class="method_details first">
|
663
|
+
<p class="signature first" id="failed?-instance_method">
|
664
|
+
|
665
|
+
- (<tt>true</tt>, <tt>false</tt>) <strong>failed?</strong>
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
</p><div class="docstring">
|
670
|
+
<div class="discussion">
|
671
|
+
<p>
|
672
|
+
Has this validation failed?
|
673
|
+
</p>
|
674
|
+
|
675
|
+
|
676
|
+
</div>
|
677
|
+
</div>
|
678
|
+
<div class="tags">
|
679
|
+
<h3>Returns:</h3>
|
680
|
+
<ul class="return">
|
681
|
+
|
682
|
+
<li>
|
683
|
+
|
684
|
+
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
</li>
|
690
|
+
|
691
|
+
</ul>
|
692
|
+
|
693
|
+
</div><table class="source_code">
|
694
|
+
<tr>
|
695
|
+
<td>
|
696
|
+
<pre class="lines">
|
697
|
+
|
698
|
+
|
699
|
+
47
|
700
|
+
48
|
701
|
+
49</pre>
|
702
|
+
</td>
|
703
|
+
<td>
|
704
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 47</span>
|
705
|
+
|
706
|
+
<span class='def def kw'>def</span> <span class='failed? fid id'>failed?</span>
|
707
|
+
<span class='@passed ivar id'>@passed</span> <span class='eq op'>==</span> <span class='false false kw'>false</span>
|
708
|
+
<span class='end end kw'>end</span>
|
709
|
+
</pre>
|
710
|
+
</td>
|
711
|
+
</tr>
|
712
|
+
</table>
|
713
|
+
</div>
|
714
|
+
|
715
|
+
<div class="method_details ">
|
716
|
+
<p class="signature " id="has_run?-instance_method">
|
717
|
+
|
718
|
+
- (<tt>true</tt>, <tt>false</tt>) <strong>has_run?</strong>
|
719
|
+
|
720
|
+
|
721
|
+
|
722
|
+
</p><div class="docstring">
|
723
|
+
<div class="discussion">
|
724
|
+
<p>
|
725
|
+
Has this validation run?
|
726
|
+
</p>
|
727
|
+
|
728
|
+
|
729
|
+
</div>
|
730
|
+
</div>
|
731
|
+
<div class="tags">
|
732
|
+
<h3>Returns:</h3>
|
733
|
+
<ul class="return">
|
734
|
+
|
735
|
+
<li>
|
736
|
+
|
737
|
+
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
|
738
|
+
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
</li>
|
743
|
+
|
744
|
+
</ul>
|
745
|
+
|
746
|
+
</div><table class="source_code">
|
747
|
+
<tr>
|
748
|
+
<td>
|
749
|
+
<pre class="lines">
|
750
|
+
|
751
|
+
|
752
|
+
53
|
753
|
+
54
|
754
|
+
55</pre>
|
755
|
+
</td>
|
756
|
+
<td>
|
757
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 53</span>
|
758
|
+
|
759
|
+
<span class='def def kw'>def</span> <span class='has_run? fid id'>has_run?</span>
|
760
|
+
<span class='@passed ivar id'>@passed</span> <span class='neq op'>!=</span> <span class='nil nil kw'>nil</span>
|
761
|
+
<span class='end end kw'>end</span>
|
762
|
+
</pre>
|
763
|
+
</td>
|
764
|
+
</tr>
|
765
|
+
</table>
|
766
|
+
</div>
|
767
|
+
|
768
|
+
<div class="method_details ">
|
769
|
+
<p class="signature " id="message-instance_method">
|
770
|
+
|
771
|
+
- (<tt><a href="../Object.html" title="Object">Object</a></tt>) <strong>message</strong>
|
772
|
+
|
773
|
+
|
774
|
+
|
775
|
+
</p><div class="docstring">
|
776
|
+
<div class="discussion">
|
777
|
+
<p>
|
778
|
+
The failure message for this validation.
|
779
|
+
</p>
|
780
|
+
|
781
|
+
|
782
|
+
</div>
|
783
|
+
</div>
|
784
|
+
<div class="tags">
|
785
|
+
|
786
|
+
</div><table class="source_code">
|
787
|
+
<tr>
|
788
|
+
<td>
|
789
|
+
<pre class="lines">
|
790
|
+
|
791
|
+
|
792
|
+
69
|
793
|
+
70
|
794
|
+
71</pre>
|
795
|
+
</td>
|
796
|
+
<td>
|
797
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 69</span>
|
798
|
+
|
799
|
+
<span class='def def kw'>def</span> <span class='message identifier id'>message</span>
|
800
|
+
<span class='@options ivar id'>@options</span><span class='lbrack token'>[</span><span class='symbol val'>:message</span><span class='rbrack token'>]</span> <span class='orop op'>||</span> <span class='string val'>"failed validation"</span>
|
801
|
+
<span class='end end kw'>end</span>
|
802
|
+
</pre>
|
803
|
+
</td>
|
804
|
+
</tr>
|
805
|
+
</table>
|
806
|
+
</div>
|
807
|
+
|
808
|
+
<div class="method_details ">
|
809
|
+
<p class="signature " id="passed?-instance_method">
|
810
|
+
|
811
|
+
- (<tt>true</tt>, <tt>false</tt>) <strong>passed?</strong>
|
812
|
+
|
813
|
+
|
814
|
+
|
815
|
+
</p><div class="docstring">
|
816
|
+
<div class="discussion">
|
817
|
+
<p>
|
818
|
+
Has this validation passed?
|
819
|
+
</p>
|
820
|
+
|
821
|
+
|
822
|
+
</div>
|
823
|
+
</div>
|
824
|
+
<div class="tags">
|
825
|
+
<h3>Returns:</h3>
|
826
|
+
<ul class="return">
|
827
|
+
|
828
|
+
<li>
|
829
|
+
|
830
|
+
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
|
831
|
+
|
832
|
+
|
833
|
+
|
834
|
+
|
835
|
+
</li>
|
836
|
+
|
837
|
+
</ul>
|
838
|
+
|
839
|
+
</div><table class="source_code">
|
840
|
+
<tr>
|
841
|
+
<td>
|
842
|
+
<pre class="lines">
|
843
|
+
|
844
|
+
|
845
|
+
41
|
846
|
+
42
|
847
|
+
43</pre>
|
848
|
+
</td>
|
849
|
+
<td>
|
850
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 41</span>
|
851
|
+
|
852
|
+
<span class='def def kw'>def</span> <span class='passed? fid id'>passed?</span>
|
853
|
+
<span class='@passed ivar id'>@passed</span> <span class='eq op'>==</span> <span class='true true kw'>true</span>
|
854
|
+
<span class='end end kw'>end</span>
|
855
|
+
</pre>
|
856
|
+
</td>
|
857
|
+
</tr>
|
858
|
+
</table>
|
859
|
+
</div>
|
860
|
+
|
861
|
+
<div class="method_details ">
|
862
|
+
<p class="signature " id="validates?-instance_method">
|
863
|
+
|
864
|
+
- (<tt>true</tt>, ...) <strong>validates?</strong>
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
</p><div class="docstring">
|
869
|
+
<div class="discussion">
|
870
|
+
<p>
|
871
|
+
Performs the validation, returning true or false if the validation passes
|
872
|
+
or fails, or nil if the validation will not run.
|
873
|
+
</p>
|
874
|
+
|
875
|
+
|
876
|
+
</div>
|
877
|
+
</div>
|
878
|
+
<div class="tags">
|
879
|
+
<h3>Returns:</h3>
|
880
|
+
<ul class="return">
|
881
|
+
|
882
|
+
<li>
|
883
|
+
|
884
|
+
<span class='type'>(<tt>true</tt>, <tt>false</tt>, <tt>nil</tt>)</span>
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
</li>
|
890
|
+
|
891
|
+
</ul>
|
892
|
+
|
893
|
+
</div><table class="source_code">
|
894
|
+
<tr>
|
895
|
+
<td>
|
896
|
+
<pre class="lines">
|
897
|
+
|
898
|
+
|
899
|
+
60
|
900
|
+
61
|
901
|
+
62
|
902
|
+
63
|
903
|
+
64
|
904
|
+
65
|
905
|
+
66</pre>
|
906
|
+
</td>
|
907
|
+
<td>
|
908
|
+
<pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/validation.rb', line 60</span>
|
909
|
+
|
910
|
+
<span class='def def kw'>def</span> <span class='validates? fid id'>validates?</span>
|
911
|
+
<span class='reset identifier id'>reset</span>
|
912
|
+
<span class='@passed ivar id'>@passed</span> <span class='assign token'>=</span> <span class='catch identifier id'>catch</span> <span class='symbol val'>:validation_done</span> <span class='do do kw'>do</span>
|
913
|
+
<span class='validate identifier id'>validate</span>
|
914
|
+
<span class='pass identifier id'>pass</span>
|
915
|
+
<span class='end end kw'>end</span>
|
916
|
+
<span class='end end kw'>end</span>
|
917
|
+
</pre>
|
918
|
+
</td>
|
919
|
+
</tr>
|
920
|
+
</table>
|
921
|
+
</div>
|
922
|
+
|
923
|
+
</div>
|
924
|
+
|
925
|
+
</div>
|
926
|
+
|
927
|
+
<div id="footer">
|
928
|
+
Generated on Sun Dec 20 19:49:45 2009 by
|
929
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
930
|
+
0.5.2 (ruby-1.8.7).
|
931
|
+
</div>
|
932
|
+
|
933
|
+
</body>
|
934
|
+
</html>
|