whyvalidationssuckin96 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.md +121 -0
  5. data/Rakefile +45 -0
  6. data/VERSION +1 -0
  7. data/doc/ActiveRecord/RecordInvalid.html +258 -0
  8. data/doc/ActiveRecord.html +93 -0
  9. data/doc/FalseClass.html +87 -0
  10. data/doc/NilClass.html +87 -0
  11. data/doc/Numeric.html +87 -0
  12. data/doc/Object.html +79 -0
  13. data/doc/String.html +87 -0
  14. data/doc/TrueClass.html +87 -0
  15. data/doc/WhyValidationsSuckIn96/ActiveRecord/InstanceMethods.html +156 -0
  16. data/doc/WhyValidationsSuckIn96/ActiveRecord.html +192 -0
  17. data/doc/WhyValidationsSuckIn96/AttributeBasedValidation.html +464 -0
  18. data/doc/WhyValidationsSuckIn96/SkippableValidation.html +194 -0
  19. data/doc/WhyValidationsSuckIn96/ValidatesAcceptance.html +254 -0
  20. data/doc/WhyValidationsSuckIn96/ValidatesAssociated.html +250 -0
  21. data/doc/WhyValidationsSuckIn96/ValidatesConfirmation.html +251 -0
  22. data/doc/WhyValidationsSuckIn96/ValidatesExclusion.html +388 -0
  23. data/doc/WhyValidationsSuckIn96/ValidatesFormat.html +387 -0
  24. data/doc/WhyValidationsSuckIn96/ValidatesInclusion.html +388 -0
  25. data/doc/WhyValidationsSuckIn96/ValidatesLength.html +469 -0
  26. data/doc/WhyValidationsSuckIn96/ValidatesNumericality.html +267 -0
  27. data/doc/WhyValidationsSuckIn96/ValidatesPresence.html +244 -0
  28. data/doc/WhyValidationsSuckIn96/ValidatesUniqueness.html +289 -0
  29. data/doc/WhyValidationsSuckIn96/Validation.html +934 -0
  30. data/doc/WhyValidationsSuckIn96/ValidationBuilder.html +391 -0
  31. data/doc/WhyValidationsSuckIn96/ValidationSupport/ClassMethods.html +249 -0
  32. data/doc/WhyValidationsSuckIn96/ValidationSupport/InstanceMethods.html +484 -0
  33. data/doc/WhyValidationsSuckIn96/ValidationSupport.html +168 -0
  34. data/doc/WhyValidationsSuckIn96.html +97 -0
  35. data/doc/_index.html +346 -0
  36. data/doc/class_list.html +293 -0
  37. data/doc/css/common.css +1 -0
  38. data/doc/css/full_list.css +23 -0
  39. data/doc/css/style.css +263 -0
  40. data/doc/file.README.html +173 -0
  41. data/doc/file_list.html +29 -0
  42. data/doc/index.html +173 -0
  43. data/doc/js/app.js +91 -0
  44. data/doc/js/full_list.js +39 -0
  45. data/doc/js/jquery.js +19 -0
  46. data/doc/method_list.html +462 -0
  47. data/doc/top-level-namespace.html +81 -0
  48. data/lib/whyvalidationssuckin96/attribute_based_validation.rb +46 -0
  49. data/lib/whyvalidationssuckin96/constants.rb +3 -0
  50. data/lib/whyvalidationssuckin96/ext/blank.rb +47 -0
  51. data/lib/whyvalidationssuckin96/macros/validates_acceptance.rb +36 -0
  52. data/lib/whyvalidationssuckin96/macros/validates_associated.rb +33 -0
  53. data/lib/whyvalidationssuckin96/macros/validates_confirmation.rb +40 -0
  54. data/lib/whyvalidationssuckin96/macros/validates_exclusion.rb +38 -0
  55. data/lib/whyvalidationssuckin96/macros/validates_format.rb +38 -0
  56. data/lib/whyvalidationssuckin96/macros/validates_inclusion.rb +38 -0
  57. data/lib/whyvalidationssuckin96/macros/validates_length.rb +98 -0
  58. data/lib/whyvalidationssuckin96/macros/validates_numericality.rb +56 -0
  59. data/lib/whyvalidationssuckin96/macros/validates_presence.rb +30 -0
  60. data/lib/whyvalidationssuckin96/macros.rb +9 -0
  61. data/lib/whyvalidationssuckin96/rails/active_record.rb +94 -0
  62. data/lib/whyvalidationssuckin96/rails/macros/validates_uniqueness.rb +87 -0
  63. data/lib/whyvalidationssuckin96/rails/macros.rb +1 -0
  64. data/lib/whyvalidationssuckin96/skippable_validation.rb +59 -0
  65. data/lib/whyvalidationssuckin96/validation.rb +88 -0
  66. data/lib/whyvalidationssuckin96/validation_builder.rb +56 -0
  67. data/lib/whyvalidationssuckin96/validation_support.rb +74 -0
  68. data/lib/whyvalidationssuckin96.rb +4 -0
  69. data/test/attribute_based_validation_test.rb +58 -0
  70. data/test/macros/validates_acceptance_test.rb +64 -0
  71. data/test/macros/validates_associated_test.rb +60 -0
  72. data/test/macros/validates_confirmation_test.rb +63 -0
  73. data/test/macros/validates_exclusion_test.rb +37 -0
  74. data/test/macros/validates_format_test.rb +43 -0
  75. data/test/macros/validates_inclusion_test.rb +37 -0
  76. data/test/macros/validates_length_test.rb +179 -0
  77. data/test/macros/validates_numericality_test.rb +129 -0
  78. data/test/macros/validates_presence_test.rb +31 -0
  79. data/test/rails/active_record_test.rb +187 -0
  80. data/test/rails/active_record_test_helper.rb +90 -0
  81. data/test/rails/macros/validates_uniqueness_test.rb +153 -0
  82. data/test/skippable_validation_test.rb +102 -0
  83. data/test/teststrap.rb +4 -0
  84. data/test/validation_builder_test.rb +62 -0
  85. data/test/validation_support_test.rb +209 -0
  86. data/test/validation_test.rb +101 -0
  87. data/whyvalidationssuckin96.gemspec +153 -0
  88. metadata +189 -0
@@ -0,0 +1,289 @@
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::ValidatesUniqueness</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> &raquo;
23
+ <a href="../WhyValidationsSuckIn96.html" title="WhyValidationsSuckIn96">WhyValidationsSuckIn96</a>
24
+ &raquo;
25
+ <span class="title">ValidatesUniqueness</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::ValidatesUniqueness
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="Validation.html" title="WhyValidationsSuckIn96::Validation">WhyValidationsSuckIn96::Validation</a></span>
50
+
51
+ <ul class="fullTree">
52
+ <li><a href="../Object.html" title="Object">Object</a></li>
53
+
54
+ <li class="next"><a href="Validation.html" title="WhyValidationsSuckIn96::Validation">WhyValidationsSuckIn96::Validation</a></li>
55
+
56
+ <li class="next">WhyValidationsSuckIn96::ValidatesUniqueness</li>
57
+
58
+ </ul>
59
+ <a href="#" class="inheritanceTree">show all</a>
60
+
61
+ </dd>
62
+
63
+
64
+
65
+
66
+
67
+
68
+ <dt class="r2">Includes:</dt>
69
+ <dd class="r2"><a href="AttributeBasedValidation.html" title="WhyValidationsSuckIn96::AttributeBasedValidation">WhyValidationsSuckIn96::AttributeBasedValidation</a>, <a href="SkippableValidation.html" title="WhyValidationsSuckIn96::SkippableValidation">WhyValidationsSuckIn96::SkippableValidation</a></dd>
70
+
71
+
72
+
73
+
74
+ <dt class="r1 last">Defined in:</dt>
75
+ <dd class="r1 last">lib/whyvalidationssuckin96/rails/macros/validates_uniqueness.rb</dd>
76
+
77
+ </dl>
78
+ <div class="clear"></div>
79
+
80
+ <h2>Overview</h2><div class="docstring">
81
+ <div class="discussion">
82
+ <p>
83
+ Checks to see if a given attribute is present in any other records in the
84
+ databaser
85
+ </p>
86
+
87
+
88
+ </div>
89
+ </div>
90
+ <div class="tags">
91
+
92
+ <div class="examples">
93
+ <h3>Examples:</h3>
94
+
95
+ <h4>
96
+ Default usage
97
+
98
+ </h4>
99
+ <pre class="example code"> <span class='setup_validations identifier id'>setup_validations</span> <span class='do do kw'>do</span>
100
+ <span class='validates_uniqueness_of identifier id'>validates_uniqueness_of</span> <span class='symbol val'>:name</span>
101
+ <span class='end end kw'>end</span>
102
+ </pre>
103
+
104
+ <h4>
105
+ Check in a case sensitive fashion
106
+
107
+ </h4>
108
+ <pre class="example code"> <span class='setup_validations identifier id'>setup_validations</span> <span class='do do kw'>do</span>
109
+ <span class='validates_uniqueness_of identifier id'>validates_uniqueness_of</span> <span class='symbol val'>:name</span><span class='comma token'>,</span> <span class='symbol val'>:case_sensitive</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='true true kw'>true</span>
110
+ <span class='end end kw'>end</span>
111
+ </pre>
112
+
113
+ <h4>
114
+ Scope uniqueness to another attribute
115
+
116
+ </h4>
117
+ <pre class="example code"> <span class='setup_validations identifier id'>setup_validations</span> <span class='do do kw'>do</span>
118
+ <span class='validates_uniqueness_of identifier id'>validates_uniqueness_of</span> <span class='symbol val'>:name</span><span class='comma token'>,</span> <span class='symbol val'>:scope</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='symbol val'>:account_id</span>
119
+ <span class='end end kw'>end</span>
120
+ </pre>
121
+
122
+ <h4>
123
+ Scope uniqueness to multiple other attributes
124
+
125
+ </h4>
126
+ <pre class="example code"> <span class='setup_validations identifier id'>setup_validations</span> <span class='do do kw'>do</span>
127
+ <span class='validates_uniqueness_of identifier id'>validates_uniqueness_of</span> <span class='symbol val'>:name</span><span class='comma token'>,</span> <span class='symbol val'>:scope</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:account_id</span><span class='comma token'>,</span> <span class='symbol val'>:domain</span><span class='rbrack token'>]</span>
128
+ <span class='end end kw'>end</span>
129
+ </pre>
130
+
131
+ <h4>
132
+ When used with STI, check only uniqueness of records of the current type
133
+
134
+ </h4>
135
+ <pre class="example code"> <span class='setup_validations identifier id'>setup_validations</span> <span class='do do kw'>do</span>
136
+ <span class='validates_uniqueness_of identifier id'>validates_uniqueness_of</span> <span class='symbol val'>:name</span><span class='comma token'>,</span> <span class='symbol val'>:base_class_scope</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='false false kw'>false</span>
137
+ <span class='end end kw'>end</span>
138
+ </pre>
139
+
140
+ </div>
141
+
142
+ </div>
143
+ <h2>Constant Summary</h2>
144
+
145
+ <dl class="constants">
146
+
147
+ <dt id="DefaultOptions-constant ">DefaultOptions =
148
+ <span class="summary_desc"></span>
149
+ </dt>
150
+ <dd><pre class="code"><span class='lbrace token'>{</span><span class='symbol val'>:message</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;has already been taken&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:case_sensitive</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='false false kw'>false</span><span class='comma token'>,</span> <span class='symbol val'>:base_class_scope</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='true true kw'>true</span><span class='rbrace token'>}</span>
151
+ </pre></dd>
152
+
153
+ </dl>
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <h3 class="inherited">Constants inherited from <a href="Validation.html" title="WhyValidationsSuckIn96::Validation">WhyValidationsSuckIn96::Validation</a></h3>
170
+ <p class="inherited"><a href="Validation.html#DefaultOptions-constant" title="DefaultOptions">DefaultOptions</a></p>
171
+
172
+
173
+ <h2>Instance Method Summary</h2>
174
+
175
+ <ul class="summary">
176
+
177
+ <li class="public ">
178
+ <span class="summary_signature">
179
+
180
+ <a href="#validate-instance_method" title="#validate (instance method)">- (Object) <strong>validate</strong> </a>
181
+
182
+
183
+
184
+ </span>
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+ <span class="summary_desc"></span>
193
+
194
+ </li>
195
+
196
+
197
+ </ul>
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ <h3 class="inherited">Methods included from <a href="AttributeBasedValidation.html" title="WhyValidationsSuckIn96::AttributeBasedValidation">WhyValidationsSuckIn96::AttributeBasedValidation</a></h3>
210
+ <p class="inherited"><a href="AttributeBasedValidation.html#attribute-instance_method" title="#attribute">#attribute</a>, <a href="AttributeBasedValidation.html#attribute_value-instance_method" title="#attribute_value">#attribute_value</a>, <a href="AttributeBasedValidation.html#initialize-instance_method" title="#initialize">#initialize</a></p>
211
+
212
+
213
+
214
+
215
+
216
+
217
+ <h3 class="inherited">Methods inherited from <a href="Validation.html" title="WhyValidationsSuckIn96::Validation">WhyValidationsSuckIn96::Validation</a></h3>
218
+ <p class="inherited"><a href="Validation.html#failed%3F-instance_method" title="#failed?">#failed?</a>, <a href="Validation.html#has_run%3F-instance_method" title="#has_run?">#has_run?</a>, <a href="Validation.html#initialize-instance_method" title="#initialize">#initialize</a>, <a href="Validation.html#message-instance_method" title="#message">#message</a>, <a href="Validation.html#new_subclass-class_method" title="new_subclass">new_subclass</a>, <a href="Validation.html#passed%3F-instance_method" title="#passed?">#passed?</a>, <a href="Validation.html#validates%3F-instance_method" title="#validates?">#validates?</a></p>
219
+ <div id="constructor_details" class="method_details_list">
220
+ <h2>Constructor Details</h2>
221
+
222
+ <p class="notice">This class inherits a constructor from <a href="AttributeBasedValidation.html#initialize-instance_method" title="WhyValidationsSuckIn96::AttributeBasedValidation">WhyValidationsSuckIn96::AttributeBasedValidation</a></p>
223
+
224
+ </div>
225
+
226
+
227
+ <div id="instance_method_details" class="method_details_list">
228
+ <h2>Instance Method Details</h2>
229
+
230
+
231
+ <div class="method_details first">
232
+ <p class="signature first" id="validate-instance_method">
233
+
234
+ - (<tt><a href="../Object.html" title="Object">Object</a></tt>) <strong>validate</strong>
235
+
236
+
237
+
238
+ </p><table class="source_code">
239
+ <tr>
240
+ <td>
241
+ <pre class="lines">
242
+
243
+
244
+ 38
245
+ 39
246
+ 40
247
+ 41
248
+ 42
249
+ 43
250
+ 44
251
+ 45
252
+ 46
253
+ 47
254
+ 48
255
+ 49</pre>
256
+ </td>
257
+ <td>
258
+ <pre class="code"><span class="info file"># File 'lib/whyvalidationssuckin96/rails/macros/validates_uniqueness.rb', line 38</span>
259
+
260
+ <span class='def def kw'>def</span> <span class='validate identifier id'>validate</span>
261
+ <span class='super super kw'>super</span>
262
+ <span class='results identifier id'>results</span> <span class='assign token'>=</span> <span class='find_results identifier id'>find_results</span>
263
+ <span class='result_ids identifier id'>result_ids</span> <span class='assign token'>=</span> <span class='results identifier id'>results</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span> <span class='lbrace token'>{</span> <span class='bitor op'>|</span><span class='r identifier id'>r</span><span class='bitor op'>|</span> <span class='r identifier id'>r</span><span class='lbrack token'>[</span><span class='scope_primary_key identifier id'>scope_primary_key</span><span class='rbrack token'>]</span> <span class='rbrace token'>}</span>
264
+ <span class='if if kw'>if</span> <span class='results identifier id'>results</span><span class='dot token'>.</span><span class='empty? fid id'>empty?</span> <span class='orop op'>||</span> <span class='result_ids identifier id'>result_ids</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='validatable identifier id'>validatable</span><span class='lbrack token'>[</span><span class='scope_primary_key identifier id'>scope_primary_key</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
265
+ <span class='pass identifier id'>pass</span>
266
+ <span class='elsif elsif kw'>elsif</span> <span class='notop op'>!</span><span class='results identifier id'>results</span><span class='dot token'>.</span><span class='empty? fid id'>empty?</span> <span class='andop op'>&amp;&amp;</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:case_sensitive</span><span class='rbrack token'>]</span>
267
+ <span class='lparen token'>(</span><span class='results identifier id'>results</span><span class='dot token'>.</span><span class='any? fid id'>any?</span> <span class='lbrace token'>{</span> <span class='bitor op'>|</span><span class='r identifier id'>r</span><span class='bitor op'>|</span> <span class='r identifier id'>r</span><span class='lbrack token'>[</span><span class='attribute identifier id'>attribute</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='eq op'>==</span> <span class='attribute_value identifier id'>attribute_value</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='rbrace token'>}</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='fail identifier id'>fail</span> <span class='colon op'>:</span> <span class='pass identifier id'>pass</span>
268
+ <span class='else else kw'>else</span>
269
+ <span class='fail identifier id'>fail</span>
270
+ <span class='end end kw'>end</span>
271
+ <span class='end end kw'>end</span>
272
+ </pre>
273
+ </td>
274
+ </tr>
275
+ </table>
276
+ </div>
277
+
278
+ </div>
279
+
280
+ </div>
281
+
282
+ <div id="footer">
283
+ Generated on Sun Dec 20 19:49:46 2009 by
284
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
285
+ 0.5.2 (ruby-1.8.7).
286
+ </div>
287
+
288
+ </body>
289
+ </html>