Created
July 23, 2008 16:22
-
-
Save jugglebird/1807 to your computer and use it in GitHub Desktop.
Turning a string into a class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Turning a string into a class. | |
| def class_from_string(class_string) | |
| clazz = class_string.split("::").inject(Object) { |obj, const| obj.const_get(const) } | |
| instance = clazz.new | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment