def_class(superklass=Object, methodname='result')
Instance Public methods
Define unnamed class which has methodname as instance method, and return it.
example:
1 2 3 4 5 6 7 8 9 10 | class MyClass_ def initialize(arg1, arg2) @arg1 = arg1; @arg2 = arg2 end end filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml erb = ERB . new ( File .read(filename)) erb.filename = filename MyClass = erb.def_class(MyClass_, 'render()' ) print MyClass. new ( 'foo' , 123 ).render() |
Please login to continue.