doc/file.README.html in schemacop-2.4.4 vs doc/file.README.html in schemacop-2.4.5
- old
+ new
@@ -668,10 +668,22 @@
</span><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:foo</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='lbrace'>{</span> <span class='label'>bar:</span> <span class='symbol'>:baz</span> <span class='rbrace'>}</span> <span class='kw'>do</span>
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:foo</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
+
+<span class='comment'># You can also specify blocks (without params) as defaults that will be
+</span><span class='comment'># evaluated at time of validation.
+</span><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:year</span><span class='comma'>,</span> <span class='symbol'>:integer</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span> <span class='rbrace'>}</span>
+<span class='kw'>end</span>
+
+<span class='comment'># If, for some very specific reason, you *need* the default to be an actual
+</span><span class='comment'># proc, wrap it inside another proc.
+</span><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:myproc</span><span class='comma'>,</span> <span class='const'>Proc</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='int'>42</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
+<span class='kw'>end</span>
</code></pre>
<h3>Required data points</h3>
<p>Note that any <em>required</em> validation is done before applying the defaults. If you
@@ -809,10 +821,10 @@
<p>Copyright (c) 2020 Sitrox. See <code>LICENSE</code> for further details.</p>
</div></div>
<div id="footer">
- Generated on Mon Mar 9 10:36:30 2020 by
+ Generated on Wed May 13 10:52:04 2020 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.20 (ruby-2.6.2).
</div>
</div>
\ No newline at end of file