From: Rahul Kumar Date: 2010-09-12T22:49:26+09:00 Subject: creating trivial classes with Struct.new (adding constraints I'd like to use this form for making small classes rather than hand coding my "beans". ActionEvent = Struct.new(:source, :id, :text) do def xxx ... end end However, is there anyway I can add some constraints, such as: - source (some of the fields) must not be nil. - no changing values after creation, unless there's a method provided Essentially, the fields should correspond to attr_reader and not attr_accessor. Have i lost the open purpose of this form in my requirement. I was reading this article about it: http://blog.grayproductions.net/articles/all_about_struct (Thx to JEG). -- Posted via http://www.ruby-forum.com/.