Grimm on Recursion in Ruby
published Monday, February 27, 2012
Avdi Grimm had a post on the Code Benders site about preventing recursion in Ruby. He starts by reviewing what recursion is and a typical approach to dealing with it. Grimm has come up with a module that he's been using to wrap a method with a Thread-level flag to know whether its been called already.
Module#instance_method in his module and that got me to reading about the
UnboundMethod class, which was interesting. You can use
#instance_method to create a new
UnboundMethod instance and then associate it with another object with its
Then the next thing that I wasn't very familiar with was the
Thread stuff. Looks like you can use
#= as get/set on the thread and return (or set) the values of any thread-local variables.