Most of my system's class attributes are just text, but in this case it makes more sense to place this particular class's attributes into one single hash (from a "keep the source code pretty" aspect). Basically, a list of attributes is returned, and instead of writing a bunch of static attributes for each one, I just loop over them and collect them into a hash.
Is it a good idea to name this particular attribute @contents_hash
, as opposed to @contents
? I assume that users may figure out pretty quickly that @contents.split ' '
will return a NoMethodError: undefined method 'split' for Hash
, but on first glance of the code, is it useful to know right away that this is a hash? Do you think it will make the implementation redundant to say @contents_hash.keys
?