ERB def_method
ERB and metaprogramming I was using ERB to generate a template over the past weekend. I discovered that you can use ERB to pry open a class and add a new method into your class that will render a template. For example, you create a new ERB class and pass the template or template file into the constructor to initialize a new ERB object. Now you can call the #def_method on this newly created ERB object, and pass in the following arguments: