Sunday, March 27, 2011

Create Class Dynamically in Ruby

Sample
def create_class_dynamically(mybinding)
clazz = 'class MyClass; end'
Kernel.eval(clazz, mybinding)
end

create_class_dynamically(binding)

No comments:

Post a Comment