DEV Community

loading...

Discussion on: SQL query from the view: considered hazardous!

Collapse
kgilpin profile image
Kevin Gilpin Author • Edited

This is all you need to do to define this type with the listed attributes:

PostListItem = Struct.new(:body, :username, :attachments)
Enter fullscreen mode Exit fullscreen mode

It's now a Ruby class with a defined initialize method and many other convenience methods such as to_h.