I have a ruby class that has an Array as one of its instance variables. I'm trying to figure out how to validate data that is being pushed onto the array.
class Something
def things
@things ||= Array.new
end
end
So I can declare an instance and add stuff to the array pretty easily this way.
@s = Something.new
@s.things << "one"
@s.things << "two"
I tried to create a class method named things<<(inString) to handle the validation but that is not valid syntax. So what approach can I take?