Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / Validator.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6         <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
8         <title>Module: MCollective::Validator</title>
9
10         <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
12         <script src="../js/jquery.js" type="text/javascript"
13                 charset="utf-8"></script>
14         <script src="../js/thickbox-compressed.js" type="text/javascript"
15                 charset="utf-8"></script>
16         <script src="../js/quicksearch.js" type="text/javascript"
17                 charset="utf-8"></script>
18         <script src="../js/darkfish.js" type="text/javascript"
19                 charset="utf-8"></script>
20
21 </head>
22 <body class="module">
23
24         <div id="metadata">
25                 <div id="file-metadata">
26                         <div id="file-list-section" class="section">
27                                 <h3 class="section-header">In Files</h3>
28                                 <div class="section-body">
29                                         <ul>
30                                         
31                                                 <li><a href="../lib/mcollective/validator_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/validator.rb">lib/mcollective/validator.rb</a></li>
33                                         
34                                         </ul>
35                                 </div>
36                         </div>
37
38                         
39                 </div>
40
41                 <div id="class-metadata">
42
43                         <!-- Parent Class -->
44                         
45
46                         <!-- Namespace Contents -->
47                         
48
49                         <!-- Method Quickref -->
50                         
51                         <div id="method-list-section" class="section">
52                                 <h3 class="section-header">Methods</h3>
53                                 <ul class="link-list">
54                                         
55                                         <li><a href="#M000333">::[]</a></li>
56                                         
57                                         <li><a href="#M000335">::has_validator?</a></li>
58                                         
59                                         <li><a href="#M000332">::load_validators</a></li>
60                                         
61                                         <li><a href="#M000337">::load_validators?</a></li>
62                                         
63                                         <li><a href="#M000334">::method_missing</a></li>
64                                         
65                                         <li><a href="#M000338">::validate</a></li>
66                                         
67                                         <li><a href="#M000336">::validator_class</a></li>
68                                         
69                                 </ul>
70                         </div>
71                         
72
73                         <!-- Included Modules -->
74                         
75                 </div>
76
77                 <div id="project-metadata">
78                         
79                         
80                         <div id="fileindex-section" class="section project-section">
81                                 <h3 class="section-header">Files</h3>
82                                 <ul>
83                                 
84                                         <li class="file"><a href="../COPYING.html">COPYING</a></li>
85                                 
86                                         <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
87                                 
88                                         <li class="file"><a href="../README.html">README</a></li>
89                                 
90                                         <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
91                                 
92                                         <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
93                                 
94                                         <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
95                                 
96                                         <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
97                                 
98                                         <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
99                                 
100                                         <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
101                                 
102                                         <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
103                                 
104                                         <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
105                                 
106                                         <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
107                                 
108                                         <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
109                                 
110                                         <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
111                                 
112                                         <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
113                                 
114                                         <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
115                                 
116                                         <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
117                                 
118                                         <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
119                                 
120                                         <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
121                                 
122                                         <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
123                                 
124                                 </ul>
125                         </div>
126                         
127
128                         <div id="classindex-section" class="section project-section">
129                                 <h3 class="section-header">Class Index
130                                         <span class="search-toggle"><img src="../images/find.png"
131                                                 height="16" width="16" alt="[+]"
132                                                 title="show/hide quicksearch" /></span></h3>
133                                 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
134                                 <fieldset>
135                                         <legend>Quicksearch</legend>
136                                         <input type="text" name="quicksearch" value=""
137                                                 class="quicksearch-field" />
138                                 </fieldset>
139                                 </form>
140
141                                 <ul class="link-list">
142                                 
143                                         <li><a href="../MCollective.html">MCollective</a></li>
144                                 
145                                         <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
146                                 
147                                         <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
148                                 
149                                         <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
150                                 
151                                         <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
152                                 
153                                         <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
154                                 
155                                         <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
156                                 
157                                         <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
158                                 
159                                         <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
160                                 
161                                         <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
162                                 
163                                         <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
164                                 
165                                         <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
166                                 
167                                         <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
168                                 
169                                         <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
170                                 
171                                         <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
172                                 
173                                         <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
174                                 
175                                         <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
176                                 
177                                         <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
178                                 
179                                         <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
180                                 
181                                         <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
182                                 
183                                         <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
184                                 
185                                         <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
186                                 
187                                         <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
188                                 
189                                         <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
190                                 
191                                         <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
192                                 
193                                         <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
194                                 
195                                         <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
196                                 
197                                         <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
198                                 
199                                         <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
200                                 
201                                         <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
202                                 
203                                         <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
204                                 
205                                         <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
206                                 
207                                         <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
208                                 
209                                         <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
210                                 
211                                         <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
212                                 
213                                         <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
214                                 
215                                         <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
216                                 
217                                         <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
218                                 
219                                         <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
220                                 
221                                         <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
222                                 
223                                         <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
224                                 
225                                         <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
226                                 
227                                         <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
228                                 
229                                         <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
230                                 
231                                         <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
232                                 
233                                         <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
234                                 
235                                         <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
236                                 
237                                         <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
238                                 
239                                         <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
240                                 
241                                         <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
242                                 
243                                         <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
244                                 
245                                         <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
246                                 
247                                         <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
248                                 
249                                         <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
250                                 
251                                         <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
252                                 
253                                         <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
254                                 
255                                         <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
256                                 
257                                         <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
258                                 
259                                         <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
260                                 
261                                         <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
262                                 
263                                         <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
264                                 
265                                         <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
266                                 
267                                         <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
268                                 
269                                         <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
270                                 
271                                         <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
272                                 
273                                         <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
274                                 
275                                         <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
276                                 
277                                         <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
278                                 
279                                         <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
280                                 
281                                         <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
282                                 
283                                         <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
284                                 
285                                         <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
286                                 
287                                         <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
288                                 
289                                         <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
290                                 
291                                         <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
292                                 
293                                         <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
294                                 
295                                         <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
296                                 
297                                         <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
298                                 
299                                         <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
300                                 
301                                         <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
302                                 
303                                         <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
304                                 
305                                         <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
306                                 
307                                         <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
308                                 
309                                         <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
310                                 
311                                         <li><a href="../Array.html">Array</a></li>
312                                 
313                                         <li><a href="../Dir.html">Dir</a></li>
314                                 
315                                         <li><a href="../Object.html">Object</a></li>
316                                 
317                                         <li><a href="../String.html">String</a></li>
318                                 
319                                         <li><a href="../Symbol.html">Symbol</a></li>
320                                 
321                                 </ul>
322                                 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
323                         </div>
324
325                         
326                 </div>
327         </div>
328
329         <div id="documentation">
330                 <h1 class="module">MCollective::Validator</h1>
331
332                 <div id="description">
333                         
334                 </div>
335
336                 <!-- Constants -->
337                 
338
339                 <!-- Attributes -->
340                 
341
342                 <!-- Methods -->
343                 
344                 <div id="public-class-method-details" class="method-section section">
345                         <h3 class="section-header">Public Class Methods</h3>
346
347                 
348                         <div id="--method" class="method-detail ">
349                                 <a name="M000333"></a>
350
351                                 <div class="method-heading">
352                                 
353                                         <span class="method-name">[]</span><span
354                                                 class="method-args">(klass)</span>
355                                         <span class="method-click-advice">click to toggle source</span>
356                                 
357                                 </div>
358
359                                 <div class="method-description">
360                                         
361                                         <p>
362 Returns and instance of the Plugin class from which objects can be created.
363 Valid plugin names are
364 </p>
365 <pre>
366   :valplugin
367   &quot;valplugin&quot;
368   &quot;ValpluginValidator&quot;
369 </pre>
370                                         
371
372                                         
373                                         <div class="method-source-code"
374                                                 id="--source">
375 <pre>
376     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 18</span>
377 18:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-operator">[]</span>(<span class="ruby-identifier">klass</span>)
378 19:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
379 20:         <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">validator_class</span>(<span class="ruby-identifier">klass</span>)
380 21:       <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/.*Validator$/</span>))
381 22:         <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">validator_class</span>(<span class="ruby-identifier">klass</span>)
382 23:       <span class="ruby-keyword kw">end</span>
383 24: 
384 25:       <span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">klass</span>)
385 26:     <span class="ruby-keyword kw">end</span></pre>
386                                         </div>
387                                         
388                                 </div>
389
390                                 
391                         </div>
392
393                 
394                         <div id="has-validator--method" class="method-detail ">
395                                 <a name="M000335"></a>
396
397                                 <div class="method-heading">
398                                 
399                                         <span class="method-name">has_validator?</span><span
400                                                 class="method-args">(validator)</span>
401                                         <span class="method-click-advice">click to toggle source</span>
402                                 
403                                 </div>
404
405                                 <div class="method-description">
406                                         
407                                         <p class="missing-docs">(Not documented)</p>
408                                         
409
410                                         
411                                         <div class="method-source-code"
412                                                 id="has-validator--source">
413 <pre>
414     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 37</span>
415 37:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">has_validator?</span>(<span class="ruby-identifier">validator</span>)
416 38:       <span class="ruby-identifier">const_defined?</span>(<span class="ruby-identifier">validator_class</span>(<span class="ruby-identifier">validator</span>))
417 39:     <span class="ruby-keyword kw">end</span></pre>
418                                         </div>
419                                         
420                                 </div>
421
422                                 
423                         </div>
424
425                 
426                         <div id="load-validators-method" class="method-detail ">
427                                 <a name="M000332"></a>
428
429                                 <div class="method-heading">
430                                 
431                                         <span class="method-name">load_validators</span><span
432                                                 class="method-args">()</span>
433                                         <span class="method-click-advice">click to toggle source</span>
434                                 
435                                 </div>
436
437                                 <div class="method-description">
438                                         
439                                         <p>
440 Loads the validator plugins. Validators will only be loaded every 5 minutes
441 </p>
442                                         
443
444                                         
445                                         <div class="method-source-code"
446                                                 id="load-validators-source">
447 <pre>
448     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 6</span>
449  6:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_validators</span>
450  7:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">load_validators?</span>
451  8:         <span class="ruby-ivar">@last_load</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span>
452  9:         <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">find_and_load</span>(<span class="ruby-value str">&quot;validator&quot;</span>)
453 10:       <span class="ruby-keyword kw">end</span>
454 11:     <span class="ruby-keyword kw">end</span></pre>
455                                         </div>
456                                         
457                                 </div>
458
459                                 
460                         </div>
461
462                 
463                         <div id="load-validators--method" class="method-detail ">
464                                 <a name="M000337"></a>
465
466                                 <div class="method-heading">
467                                 
468                                         <span class="method-name">load_validators?</span><span
469                                                 class="method-args">()</span>
470                                         <span class="method-click-advice">click to toggle source</span>
471                                 
472                                 </div>
473
474                                 <div class="method-description">
475                                         
476                                         <p class="missing-docs">(Not documented)</p>
477                                         
478
479                                         
480                                         <div class="method-source-code"
481                                                 id="load-validators--source">
482 <pre>
483     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 45</span>
484 45:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_validators?</span>
485 46:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@last_load</span>.<span class="ruby-identifier">nil?</span>
486 47: 
487 48:       (<span class="ruby-ivar">@last_load</span> <span class="ruby-operator">-</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">300</span>
488 49:     <span class="ruby-keyword kw">end</span></pre>
489                                         </div>
490                                         
491                                 </div>
492
493                                 
494                         </div>
495
496                 
497                         <div id="method-missing-method" class="method-detail ">
498                                 <a name="M000334"></a>
499
500                                 <div class="method-heading">
501                                 
502                                         <span class="method-name">method_missing</span><span
503                                                 class="method-args">(method, *args, &block)</span>
504                                         <span class="method-click-advice">click to toggle source</span>
505                                 
506                                 </div>
507
508                                 <div class="method-description">
509                                         
510                                         <p>
511 Allows validation plugins to be called like module methods : <a
512 href="Validator.html#M000338">Validator.validate()</a>
513 </p>
514                                         
515
516                                         
517                                         <div class="method-source-code"
518                                                 id="method-missing-source">
519 <pre>
520     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 29</span>
521 29:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
522 30:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_validator?</span>(<span class="ruby-identifier">method</span>)
523 31:         <span class="ruby-identifier">validator</span> = <span class="ruby-constant">Validator</span>[<span class="ruby-identifier">method</span>].<span class="ruby-identifier">validate</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
524 32:       <span class="ruby-keyword kw">else</span>
525 33:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">ValidatorError</span>, <span class="ruby-node">&quot;Unknown validator: '#{method}'.&quot;</span>
526 34:       <span class="ruby-keyword kw">end</span>
527 35:     <span class="ruby-keyword kw">end</span></pre>
528                                         </div>
529                                         
530                                 </div>
531
532                                 
533                         </div>
534
535                 
536                         <div id="validate-method" class="method-detail ">
537                                 <a name="M000338"></a>
538
539                                 <div class="method-heading">
540                                 
541                                         <span class="method-name">validate</span><span
542                                                 class="method-args">(validator, validation)</span>
543                                         <span class="method-click-advice">click to toggle source</span>
544                                 
545                                 </div>
546
547                                 <div class="method-description">
548                                         
549                                         <p>
550 Generic validate method that will call the correct validator plugin based
551 on the type of the validation parameter
552 </p>
553                                         
554
555                                         
556                                         <div class="method-source-code"
557                                                 id="validate-source">
558 <pre>
559     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 53</span>
560 53:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">validator</span>, <span class="ruby-identifier">validation</span>)
561 54:       <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">load_validators</span>
562 55: 
563 56:       <span class="ruby-keyword kw">begin</span>
564 57:         <span class="ruby-keyword kw">if</span> [<span class="ruby-identifier">:integer</span>, <span class="ruby-identifier">:boolean</span>, <span class="ruby-identifier">:float</span>, <span class="ruby-identifier">:number</span>, <span class="ruby-identifier">:string</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">validation</span>)
565 58:           <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">typecheck</span>(<span class="ruby-identifier">validator</span>, <span class="ruby-identifier">validation</span>)
566 59: 
567 60:         <span class="ruby-keyword kw">else</span>
568 61:           <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">validation</span>
569 62:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Regexp</span>,<span class="ruby-constant">String</span>
570 63:               <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">regex</span>(<span class="ruby-identifier">validator</span>, <span class="ruby-identifier">validation</span>)
571 64: 
572 65:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Symbol</span>
573 66:               <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">validation</span>, <span class="ruby-identifier">validator</span>)
574 67: 
575 68:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
576 69:               <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">array</span>(<span class="ruby-identifier">validator</span>, <span class="ruby-identifier">validation</span>)
577 70: 
578 71:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Class</span>
579 72:               <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">typecheck</span>(<span class="ruby-identifier">validator</span>, <span class="ruby-identifier">validation</span>)
580 73:           <span class="ruby-keyword kw">end</span>
581 74:         <span class="ruby-keyword kw">end</span>
582 75:       <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
583 76:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">ValidatorError</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>
584 77:       <span class="ruby-keyword kw">end</span>
585 78:     <span class="ruby-keyword kw">end</span></pre>
586                                         </div>
587                                         
588                                 </div>
589
590                                 
591                         </div>
592
593                 
594                         <div id="validator-class-method" class="method-detail ">
595                                 <a name="M000336"></a>
596
597                                 <div class="method-heading">
598                                 
599                                         <span class="method-name">validator_class</span><span
600                                                 class="method-args">(validator)</span>
601                                         <span class="method-click-advice">click to toggle source</span>
602                                 
603                                 </div>
604
605                                 <div class="method-description">
606                                         
607                                         <p class="missing-docs">(Not documented)</p>
608                                         
609
610                                         
611                                         <div class="method-source-code"
612                                                 id="validator-class-source">
613 <pre>
614     <span class="ruby-comment cmt"># File lib/mcollective/validator.rb, line 41</span>
615 41:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">validator_class</span>(<span class="ruby-identifier">validator</span>)
616 42:       <span class="ruby-node">&quot;#{validator.to_s.capitalize}Validator&quot;</span>
617 43:     <span class="ruby-keyword kw">end</span></pre>
618                                         </div>
619                                         
620                                 </div>
621
622                                 
623                         </div>
624
625                 
626                 </div>
627         
628
629         </div>
630
631
632         <div id="rdoc-debugging-section-dump" class="debugging-section">
633         
634                 <p>Disabled; run with --debug to generate this.</p>
635         
636         </div>
637
638         <div id="validator-badges">
639                 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
640                 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
641                         Rdoc Generator</a> 1.1.6</small>.</p>
642         </div>
643
644 </body>
645 </html>
646