method
def_method
v2_6_3 -
Show latest stable
- Class:
ERB
def_method(mod, methodname, fname='(ERB)')public
Define methodname as instance method of mod from compiled Ruby source.
example:
filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml erb = ERB.new(File.read(filename)) erb.def_method(MyClass, 'render(arg1, arg2)', filename) print MyClass.new.render('foo', 123)