module Github::ParameterFilter

def filter!(keys, params, options={:recursive => true}) # :nodoc:

:nodoc:

Removes any keys from nested hashes that don't match predefiend keys
def filter!(keys, params, options={:recursive => true})  # :nodoc:
  case params
  when Hash, ParamsHash
    params.keys.each do |k, v|
      unless (keys.include?(k) or Github::Validations::VALID_API_KEYS.include?(k))
        params.delete(k)
      else
        filter!(keys, params[k]) if options[:recursive]
      end
    end
  when Array
    params.map! do |el|
      filter!(keys, el) if options[:recursive]
    end
  else
    params
  end
  return params
end