Method: String#safe_constantize
- Defined in:
- lib/active_support/core_ext/string/inflections.rb
permalink #safe_constantize ⇒ Object
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
See ActiveSupport::Inflector.safe_constantize.
86 87 88 |
# File 'lib/active_support/core_ext/string/inflections.rb', line 86 def safe_constantize ActiveSupport::Inflector.safe_constantize(self) end |