I’m trying to DRY my code and I think It could be done even better. The following 2 functions are “before_save” callbacks that practically do the same thing, but on a different set of attributes.
Since the code is highly similar, I was wondering if someone could help me to refactor the code?
result = normalize_generic(self.budget)
self.budget_min = result[:min]
self.budget_max = result[:max]
self.budget = result[:display]
result = normalize_generic(self.size)
self.size_min = result[:min]
self.size_max = result[:max]
self.size = result[:display]