doc/Bauxite/Context.html in bauxite-0.6.7 vs doc/Bauxite/Context.html in bauxite-0.6.8
- old
+ new
@@ -1874,18 +1874,30 @@
<div class="method-source-code" id="with_vars-source">
<pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 710</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">with_vars</span>(<span class="ruby-identifier">vars</span>)
<span class="ruby-identifier">current</span> = <span class="ruby-ivar">@variables</span>
<span class="ruby-ivar">@variables</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">vars</span>)
- <span class="ruby-keyword">yield</span>
+ <span class="ruby-identifier">ret_vars</span> = <span class="ruby-keyword">nil</span>
+
+ <span class="ruby-identifier">ret</span> = <span class="ruby-keyword">yield</span>
+
+ <span class="ruby-identifier">returned</span> = <span class="ruby-ivar">@variables</span>[<span class="ruby-string">'__RETURN__'</span>]
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">returned</span> <span class="ruby-operator">==</span> [<span class="ruby-string">'*'</span>]
+ <span class="ruby-identifier">ret_vars</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">clone</span>
+ <span class="ruby-identifier">ret_vars</span>.<span class="ruby-identifier">delete</span> <span class="ruby-string">'__RETURN__'</span>
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">returned</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
+ <span class="ruby-identifier">ret_vars</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">returned</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">k</span> }
+ <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-string">"@variables"</span>, <span class="ruby-ivar">@variables</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">variables</span>
<span class="ruby-ivar">@variables</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">raise</span>
<span class="ruby-keyword">ensure</span>
<span class="ruby-ivar">@variables</span> = <span class="ruby-identifier">current</span>
+ <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">ret_vars</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">ret_vars</span>
+ <span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>