Could Ruby Structs be useful to ActiveRecord?

The DAO pattern is totally different than the ActiveRecord pattern, so you probably won't see anything like this happen inside of AR itself. Other ORMs may do something like this, though.

If your model is just a struct, then it has no 'domain' methods...

What do you mean for ‘domain’ methods? Do you mean validations, etc? They can be implemented; the model could be a sort of “struct on steroids”… something like this:

module ActiveRecord class Struct < ::Struct def self.find end def self.all end # other various implementations end class StructFor def # retrieve table column names ActiveRecord:::Struct.new(*table_column_names) end end end

model: class User < ActiveRecord::StructFor[:users] # this returns ActiveRStruct.new(:firstname, :lastname, :active)

def before_save # … end

end

Yeah, you'd _have_ to do something like that. Then you're not implementing the ActiveRecord pattern anymore, so I don't think it'd really be appropriate.