Module: Labor::Helpers
Instance Method Summary collapse
Instance Method Details
#classify(word) ⇒ Object
3 4 5 |
# File 'lib/labor/helpers.rb', line 3 def classify(word) word.split('-').each { |part| part[0] = part[0].chr.upcase }.join end |
#constantize(camel_cased_word) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/labor/helpers.rb', line 7 def constantize(camel_cased_word) camel_cased_word = camel_cased_word.to_s if camel_cased_word.include?('-') camel_cased_word = classify(camel_cased_word) end names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_get(name) || constant.const_missing(name) end constant end |