alejandrobabio / music-api

0 stars 1 forks source link

what's the difference between musician and artist in your design? #3

Open alex-nexus opened 6 years ago

alejandrobabio commented 6 years ago

In this case, I have chosen to take advantage of STI that AR brings by default (with only adding a type field to the table and inheriting from the base model). Artist is an abstract class that has two children: Band & Musician. They are also connected to Album by polymorphism called : artist. The user of the API does not know what the Artists are in this application, he passes data of Band or Musician. In the endpoint Songs::Create the input is validated by the Grape parameters, and the "use case" receives an "artist" class that will be Band or Musician according to the input parameter (the Artist model is never used). This "artist": Band or Musician will be the owner of the song. Also, a band can have many musicians (this has not yet been added to the code).