instance method
safe_constantize
Ruby on Rails 3.2.22.5
Since v3.2.22.5Signature
safe_constantize()
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. See ActiveSupport::Inflector.safe_constantize
Examples
"Module".safe_constantize # => Module "Class".safe_constantize # => Class "blargle".safe_constantize # => nil
Source
# File activesupport/lib/active_support/core_ext/string/inflections.rb, line 65
def safe_constantize
ActiveSupport::Inflector.safe_constantize(self)
end
Defined in activesupport/lib/active_support/core_ext/string/inflections.rb line 65
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in String