EliAndrewC / sideboard

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

refactored to_dict to use a new to_dict_default_attrs attribute #75

Closed EliAndrewC closed 10 years ago

EliAndrewC commented 10 years ago

Our implementation of to_dict has two behaviors:

The problem is that I sometimes want to say, "all of the default values, plus this one other value". There was no way to do that, so I refactored to_dict to use a class property. So now I can say, e.g.

return g.to_dict(Group.to_dict_default_values + ['attendees'])
coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.1%) when pulling d31ab67d3c5c8c1d4a1eaf55a9f8a7fb44b27bb0 on to_dict_default_attrs into 99181b343847a2fbaeb46b7714faaa150d24601c on master.

EliAndrewC commented 10 years ago

Now that I think about it a little more, I'd much prefer to be able to say something like

return g.to_dict(extra=['attendees'])

So maybe I should supplement what I've already done by adding an extra parameter to to_dict. I'll probably go ahead and do that if no one objects.