mardi 2 juin 2015

Rails model is getting big, but most methods are small one-liners -- is there a pattern for cleaning up a situation like this?

We have a class that has a whole bunch of little helpers, a la:

def is_processing?
  state == PROCESSING_STATE
end

or

def activate
  ActivationService.call(self)
end

All of these are useful, and as clean and DRY as we can make them. The services are also clean and concise. But the core models of our system all have enormous model files, which seems like a smell. All advice I've found for slimming up a model is to refactor methods or extract out building logic in to services/factories, which we have done. Where do we go from here? Modules build for just one class?

Aucun commentaire:

Enregistrer un commentaire