I know that there are several useful hook methods that Ruby provides. However, I couldn't seem to find anything like a 'constant_added
' hook. The reason I would like one is because I wish to override it so that whenever a constant is added, certain other actions are performed with regards to updating some variables without having to call some sort of update method myself.
More specifically, I am trying to keep a list of all existing constants that match a particular regex, but without looping over all the existing constants searching for matches at certain intervals or updating the list whenever the last constant added matches the regex; I believe this would require an explicit method call.
If a hook does not already exist, would it be possible to create one, and if not, how might I go about getting this behavior?