title: Ruby - Merge two hashes with no like keys based on matching value
body: <p>I would like to find an efficient way to merge two hashes together and the resulting hash must contain all original data <strong>and a new key/value pair</strong> based on criteria below.  There are no keys in common between the two hashes, however the key in one hash matches the value of a key in the adjacent hash.</p>
  
  <p>Also note that the second hash is actually an array of hashes.</p>
  
  <p>I am working with a relatively large data set, so looking for an efficient solution but hoping to keep the code readable at the same time since it will likely end up in production.</p>
  
  <p><strong>Here is the structure of my data:</strong></p>
  
  <pre><code># Hash
  hsh1 = { "devicename1"=&gt;"active", "devicename2"=&gt;"passive", "devicename3"=&gt;"passive" }
  
  # Array of Hashes
  hsh2 = [ { "host" =&gt; "devicename3", "secure" =&gt; true  },
           { "host" =&gt; "devicename2", "secure" =&gt; true  },
           { "host" =&gt; "devicename1", "secure" =&gt; false } ]
  </code></pre>
  
  <p><strong>Here is what I need to accomplish:</strong></p>
  
  <p>I need to merge the data from <code>hsh1</code> into <code>hsh2</code> keeping all of the original key/value pairs in <code>hsh2</code> and adding a new key called <code>activation_status</code> using the the data in <code>hsh1</code>.</p>
  
  <p>The resulting <code>hsh2</code> would be as follows:</p>
  
  <pre><code>hsh2 = [{ "host"=&gt;"devicename3", "secure"=&gt;true,  "activation_status"=&gt;"passive" },
          { "host"=&gt;"devicename2", "secure"=&gt;true,  "activation_status"=&gt;"passive" },
          { "host"=&gt;"devicename1", "secure"=&gt;false, "activation_status"=&gt;"active"  }]
  </code></pre>
  
  <p>This may already be answered on StackOverflow but I looked for some time and couldn't find a match. My apologies in advance if this is a duplicate.</p>