Steps on integrating dry into an existing Rails app?


Hi. I’ve been checking out dry-struct/dry-types over the past week and I’ve been really impressed with it so far. I’m also planning to use dry-validations when I write the next validation parts of the app I’m working on. I have just a question though, how do you integrate this with Rails? I was thinking of just splitting the AR::Base objects into 2: the actual AR object for database stuff and another object for the actual dry-struct/dry type, with an adapter or some class to convert the database AR to the dry-struct.

Something like this:

class User < AR::Base -> just so I don't break parts of the app that use AR, the where()s and create!()s

Users::Entities::User or whatever -> contains domain-level stuff, easiest example I can think of is things like "full_name", also validations can go here

Adapter::UserToEntity or something? Just so I can go to dry-rb land from ActiveRecord

This is all in my head, I’m very unsure if this is even the right direction to go for, or if I should just scrap AR in the parts of the app that I want to put dry-rb in, any thoughts?