%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/ruby18/lib64/ruby/gems/1.8/doc/rack-1.6.1/rdoc/files/lib/rack/utils_rb.src/
Upload File :
Create Path :
Current File : //opt/alt/ruby18/lib64/ruby/gems/1.8/doc/rack-1.6.1/rdoc/files/lib/rack/utils_rb.src/M000004.html

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>build_nested_query (lib/rack/utils.rb)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/rack/utils.rb, line 179</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">prefix</span> = <span class="ruby-keyword kw">nil</span>)
      <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">value</span>
      <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
        <span class="ruby-identifier">value</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">v</span>, <span class="ruby-node">&quot;#{prefix}[]&quot;</span>)
        }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;&amp;&quot;</span>)
      <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
        <span class="ruby-identifier">value</span>.<span class="ruby-identifier">map</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">build_nested_query</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">prefix</span> <span class="ruby-value">? </span><span class="ruby-node">&quot;#{prefix}[#{escape(k)}]&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">k</span>))
        }.<span class="ruby-identifier">reject</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:empty?</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'&amp;'</span>)
      <span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span>
        <span class="ruby-identifier">prefix</span>
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;value must be a Hash&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">nil?</span>
        <span class="ruby-node">&quot;#{prefix}=#{escape(value)}&quot;</span>
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
</body>
</html>

Zerion Mini Shell 1.0