Method: String#camelcase
- Defined in:
- activesupport/lib/active_support/core_ext/string/inflections.rb
#camelcase ⇒ Object
By default, camelize
converts strings to UpperCamelCase. If the argument to camelize is set to :lower
then camelize produces lowerCamelCase.
camelize
will also convert ‘/’ to ‘::’ which is useful for converting paths to namespaces.
'active_record'.camelize # => "ActiveRecord"
'active_record'.camelize(:lower) # => "activeRecord"
'active_record/errors'.camelize # => "ActiveRecord::Errors"
'active_record/errors'.camelize(:lower) # => "activeRecord::Errors"
See ActiveSupport::Inflector.camelize.
111 112 113 114 115 116 117 118 119 120 |
# File 'activesupport/lib/active_support/core_ext/string/inflections.rb', line 111 def camelize(first_letter = :upper) case first_letter when :upper ActiveSupport::Inflector.camelize(self, true) when :lower ActiveSupport::Inflector.camelize(self, false) else raise ArgumentError, "Invalid option, use either :upper or :lower." end end |