method
safe_constantize
v8.0.0 -
Show latest stable
- Class:
String
safe_constantize()public
safe_constantize tries to find a declared constant with the name specified in the string. It returns nil when the name is not in CamelCase or is not initialized.
'Module'.safe_constantize # => Module 'Class'.safe_constantize # => Class 'blargle'.safe_constantize # => nil
1Note
How safe is this?
Could this be used against a user supplied fragment like in a url route ?