Support Ruby 1.9 by never defining methods directly on main

Ruby 2 provides #define_method on main as a private method, but we can
support 1.9 as well by including it in a module.