So here's my interpretation of things, use methods to provide the user a simple interface: a single function that somewhat intelligently produces the ideal download output given the input data structure.
Most of the checks (if statement) you make in download_this is on the combination of .data and output_extension: methods are just great for that, the entire expression is based on .data so not more tests needed.
Moreover it opens the door to supporting many more data structures. One could think of adding a method for spatial features that downloads GeoJSON or ts time series downlaoded as CSV.
I also removed the has_icon argument, this can be inferred from icon
I also fixed the automagic file name generation I PR'd, it was not correct.
So here's my interpretation of things, use methods to provide the user a simple interface: a single function that somewhat intelligently produces the ideal download output given the input data structure.
Most of the checks (
if
statement) you make indownload_this
is on the combination of.data
andoutput_extension
: methods are just great for that, the entire expression is based on.data
so not more tests needed.Moreover it opens the door to supporting many more data structures. One could think of adding a method for spatial features that downloads GeoJSON or
ts
time series downlaoded as CSV.has_icon
argument, this can be inferred fromicon