ar2dto
ar2dto copied to clipboard
Experiment using Ruby's 3.2 `Data` structures for the DTOs
trafficstars
These Data objects are similar to Structs but they are immutable. This property sounds interesting for the DTOs that this gem generates. There might be some challenges though, like how to keep these DTOs be ActiveModel compliant, or having methods like ==.
One option could be that if you set active_model_compliace to false then you get a Data object, otherwise you get what you get today. If this feels too strict, Data.define classes can be extended in theory, so they might be able to provide enough ActiveModel stuff to make Rails happy.