Class: Penetrator::Inflector
- Inherits:
-
Object
- Object
- Penetrator::Inflector
- Defined in:
- lib/penetrator/inflector.rb
Class Method Summary collapse
-
.camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object
File activesupport/lib/active_support/inflector.rb, line 178.
Instance Method Summary collapse
Class Method Details
.camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object
File activesupport/lib/active_support/inflector.rb, line 178
9 10 11 12 13 14 15 |
# File 'lib/penetrator/inflector.rb', line 9 def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) if first_letter_in_uppercase lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } else lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1] end end |
Instance Method Details
#constantize(camel_cased_word) ⇒ Object
:nodoc:
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/penetrator/inflector.rb', line 36 def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end |