The question should be simple, but i’m thinking what the best way to do this is. Simply, there is a User model and a Quest model. A user has one quest. Now, i just want to check whether a user’s quest is expired.
I thought that i would have to put expired? as an instance method to quest. Now, i can do something like :
current_user.quest.expired?
or even create a delegate later, to make it like :
current_user.quest_expired?
However, there is a nuisance. If the user does not have a quest, this one will return with a nil error. I would not want to have a check beforehand or create a different method for the User model, because i feel that this breaks encapsulation.
How would you do it ?
It’s usually done with: