Engineer at GitHub, graduate of + former teacher at Flatiron School. Cat lover, but I admit I have a dog. Supporting students and junior devs through https://www.break-in.tech/
I included the final version of the PurchaseHandler service class towards the end of the post. I removed the #credit_card attr_reader as it wasn't being used. The #purchase attribute is set in the #create_purchase method.
Also keep in mind that the code for actually creating a purchase is not described here and isn't totally relevant--just an example to illustrate how we can use some of these super helpful Active Model modules :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Glad you found it helpful!
I included the final version of the
PurchaseHandler
service class towards the end of the post. I removed the#credit_card
attr_reader as it wasn't being used. The#purchase
attribute is set in the#create_purchase
method.Also keep in mind that the code for actually creating a purchase is not described here and isn't totally relevant--just an example to illustrate how we can use some of these super helpful Active Model modules :)