def assert_required_keys(hash, params)
      params[:required] ||= []
      pending_keys = params[:required] - hash.keys
      raise(ArgumentError, "Required key(s) not present: #{pending_keys.join(', ')}") unless pending_keys.empty?
    end
def assert_required_keys(hash, params)
      params[:required] ||= []
      pending_keys = params[:required] - hash.keys
      raise(ArgumentError, "Required key(s) not present: #{pending_keys.join(', ')}") unless pending_keys.empty?
    end
http://pablomanrubia.com/2011/03/extending-ruby-to-validate-required-keys-in-a-hash-table/
def assert_required_keys(hash, params)
  params[:required] ||= []
  params[:optional] ||= []
  assert_valid_keys(hash, params[:required] + params[:optional])
  pending_keys = params[:required] - hash.keys
  raise(ArgumentError, "Required key(s) not present: #{pending_keys.join(', ')}") unless pending_keys.empty?
end