In the land of Ruby projects, I work on several projects that are highly dynamic in nature. In those projects, I am often creating a reference to a class at run time from a string based name (think dynamic API end-point registration). Those of you from the Rails world may be thinking of ActiveSupport's constantize functionality, which I have happily used in several Rails projects.

What about plain Ruby applications that require the same functionality of creating a class reference from a string? I don't want to use ActiveSupport for just one method, so I usually end up creating a module to accomplish the same thing. After doing this on 3 or 4 projects, it occurred to me that creating light weight gem that creates the class reference would DRY up my code a bit.

So, I have created Begetter. Admittedly this gem was created mostly to address my immediate needs and is laughably small.

This usage is extremely simple. Call Begetter.get with the name of the class and Begetter will return a reference to the class constant:

class FooBar; end

klass_name = 'FooBar'
klass = Begetter.get(klass_name)

foo_bar =
#=> FooBar

Object creation functionality might be a worth addition, but the class reference addressed the most immediate need.

I've begun using it in 3 of my own projects and it has helped clean up the code a bit, with out adding much overhead. Mission accomplished.