Thoughts on Interfaces for Models

I recently had to build an interesting model that stored values for a JWT in order to implement an allow list style revocation strategy. After some feedback from another developer it became clear the interface for that model needed to be optimized. Here’s a quick description of the “behavior” of that model: All of the columns are read only after creation It’s dependent on a User record assocation - thus requires a validation It has an expiration time that is also stored, but set to a pre-determined amount of time It’s jti column value is generated by the model itself since it is a “propietary” action per record Given this set of behavior we can infer that since the expires_at column and jti are both self generated in the model code, the only attribute required for creation is the associated User record. ...

February 11, 2021 · 2 min · JD