title: How to pass parameters from a yaml file to a constructor, without expicitly mentioning each one?
body: <p>I have this initialiser script for setting my RabbitMq connection using Bunny:</p>
  
  <pre><code>require 'yaml'
  config = YAML.load_file('config/rabbitmq.yml')
  
  puts config[Rails.env]
  # $bunny = Bunny.new(config[Rails.env])
  
  $bunny = Bunny.new(:host =&gt; config[Rails.env]["host"],
           :vhost =&gt; config[Rails.env]["vhost"],
           :user =&gt; config[Rails.env]["user"],
           :password =&gt; config[Rails.env]["password"],
  )
  
  $bunny.start
  $bunny_channel = $bunny.create_channel
  </code></pre>
  
  <p>The contents of <code>config[Rails.env]</code> are:</p>
  
  <pre><code>{"&lt;&lt;"=&gt;nil, "host"=&gt;"spotted-monkey.rmq.cloudamqp.com", "user"=&gt;"myuser", "password"=&gt;"mypassord", "vhost"=&gt;"myvhost"}
  </code></pre>
  
  <p>The verbose syntax of the <code>Bunny.new</code> command works correctly. However, when I comment out the verbose block, and leave this syntax:</p>
  
  <pre><code>$bunny = Bunny.new(config[Rails.env])
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>session.rb:296:in `rescue in start': Could not establish TCP connection to any of the configured hosts (Bunny::TCPConnectionFailedForAllHosts)
  </code></pre>
  
  <p>I was expecting it to work, since the keys are the same in both cases. Is there any way to call the constructor without specifying each parameter explicitly?</p>
  
  <p>I tried to remove the <code>"&lt;&lt;"=&gt;nil</code> line from the yaml file, with no change in behaviour.</p>