Indeed, that’s a wise use of
protected (honestly I don’t see lots of these 😅). And it’s true that in non-pure data classes it might be easier to use. From a puristic POV, it’s not immutable per-se since state changes after creation.
I find that in Ruby, trying to stick to the immutable object ideal first and foremost helps…
The style guide holds that a class structure should be:
instance methods (private ones after public ones obviously).
Hence, for me, if the class is 40–80 lines long (which is ideal in my POV), it is usually fairly easy to spot those class methods.
Indeed this option doesn’t seem to be too useful, given that the main use of
protected is to handle calls between two instances of the same class (which do not exist for the singleton class, of course). There is a small glitch which seems mostly syntax-concerned (implicit vs. explicit receiver, even within the singleton class — private would not work…