I have the name of a class and I want to create an instance of that class so that I can loop through each rails attribute that is present in the schema of that class.
In rails you can just do:
clazz = 'ExampleClass'.constantize
In pure ruby:
clazz = Object.const_get('ExampleClass')
with modules:
module Foo class Bar end end
you would use
> clazz = 'Foo::Bar'.split('::').inject(Object) {|o,c| o.const_get c} => Foo::Bar > clazz.new => #