Class: String
Overview
:nodoc:
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#constantize ⇒ Object
Constantize tries to find a declared constant with the name specified in the string.
Instance Method Details
#blank? ⇒ Boolean
105 106 107 |
# File 'lib/awsbase/support.rb', line 105 def blank? empty? || strip.empty? end |
#constantize ⇒ Object
Constantize tries to find a declared constant with the name specified in the string. It raises a NameError when the name is not in CamelCase or is not initialized.
Examples
"Module".constantize #=> Module
"Class".constantize #=> Class
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/awsbase/support.rb', line 42 def constantize() camel_cased_word = self names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_get(name, false) || constant.const_missing(name) end constant end |