Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Created April 26, 2014 16:18
Show Gist options
  • Save cheeyeo/11324200 to your computer and use it in GitHub Desktop.
Save cheeyeo/11324200 to your computer and use it in GitHub Desktop.
Object.const get
def string_to_constant(constant_name)
constant_name.split("::").inject(Object) { |s,e| s.const_get(e) }
end
class Article; end
string_to_constant("Article")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment