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
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
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).