title: Most efficient way to format a hash of data?
body: <p>I am using this array of hashes to do a batch insert into a mongo DB. Each hash was populated by parsing a text file so the formatting of fields are in an unpredictable format.  It might look something like:</p>
  
  <pre><code>{date =&gt; "March 5", time =&gt; "05:22:21", first_name = "John", middle_initial = "JJ", ...}
  </code></pre>
  
  <p>And I would have a series of formatting functions.  So maybe:</p>
  
  <pre><code>def format_date
  ..convert if needed..
  end
  
  def format_time
  ...
  end
  </code></pre>
  
  <p>How would I go about calling the formatting functions on various records?  I could see doing some kind of lambda call where I iterate through the hash and call a format_record_name function, but not all records will have formatting functions.  For instance above the first_name record wouldn't need one. Any ideas?</p>