def symbolize_hash hash, options = {}
      return {} if (hash.nil? or hash.empty?)
      (raise ExpectationFailedError.new("symbolize_hash called without a hash")) unless hash.is_a?(Hash)
      hash.inject({}) do |result, (k,v)|
        key = options[:downcase] ? k.to_s.downcase.to_sym : k.to_s.to_sym
        if v.is_a?(Hash) then
          result[key] = symbolize_hash(v)
        elsif v.is_a?(Regexp) && options[:rewrite_regex] then
          result[key] = v.inspect[1..-2]
        else
          result[key] = v
        end
        result
      end
    end
def symbolize_hash hash, options = {}
      return {} if (hash.nil? or hash.empty?)
      (raise ExpectationFailedError.new("symbolize_hash called without a hash")) unless hash.is_a?(Hash)
      hash.inject({}) do |result, (k,v)|
        key = options[:downcase] ? k.to_s.downcase.to_sym : k.to_s.to_sym
        if v.is_a?(Hash) then
          result[key] = symbolize_hash(v)
        elsif v.is_a?(Regexp) && options[:rewrite_regex] then
          result[key] = v.inspect[1..-2]
        else
          result[key] = v
        end
        result
      end
    end
Given a hash, rewrite keys to symbols

 @param [Hash] hash the hash to symbolize
 @param [Hash] options specify how to process the hash
 @option options [Boolean] :rewrite_regex if the value is a regex and this is true, convert it to a string
 @option options [Boolean] :downcase if true, downcase the keys as well
 @raise [ExpectationFailedError] if hash is not a hash