ruby where to define structs

idioms, ruby, struct

Solution

You can define it anywhere really. Just make sure to require the file wherever needed

EDIT If you want some structure, it will be nice to have a folder where you define the structs and classes you need and require all files in that folder inside your app

Problem

I know I can define new structs in ruby by doing ``` Person = Struct.new(:first_name, :last_name) ``` What I'm wondering is what is the appropriate place to define this struct (and other structs I'll be using). `Person` will be used throughout the system. In other languages such as Java, I would typically define `Person` as another class, but with this inline definition in Ruby, where is the correct place to define it so it is available to the entire system?

Original source