nattaponaie / nimble-challenge

0 stars 0 forks source link

Externalizing scraping logic out of the model #16

Open olivierobert opened 4 years ago

olivierobert commented 4 years ago

To be true to single responsibility, prefer moving out process_search from the model KeywordData.

A specific Job or Service class would be a great solution.

ActiveRecord models do usually quite a lot already as they manage both entity definition and data persistence. So let's not add more responsibilities there. It would help greatly in code maintenance and testing.

nattaponaie commented 4 years ago

At first, I intended to move logic to be a function inside each model to make the code readability (separate from controller and make controller to be clean).

However, since process_search is used in Rails task so I decided to moved it out.