Archive of posts in Nov, 2026
-
Polymorphism on a single object in Ruby
By dynamically redefining singleton methods on an object and instance methods on an extended module, we can achieve polymorphism on a single object based on the context. With the new Proc#refinedmethod in Ruby 4.1, this can be done in a simpler way.