Skip to content

Instantly share code, notes, and snippets.

@jugglebird
Created July 23, 2008 16:22
Show Gist options
  • Select an option

  • Save jugglebird/1807 to your computer and use it in GitHub Desktop.

Select an option

Save jugglebird/1807 to your computer and use it in GitHub Desktop.
Turning a string into a class
# 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