diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-10 16:03:44 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-10 16:03:44 +0000 |
commit | d239ac40fa28630a3e683caf28d71bdbfb921ba0 (patch) | |
tree | b1a12eb8f78ca9ed230bf0d1f78d59fdb78b856d /activesupport/lib | |
parent | 38e55bac6197c937c2f1ef356ff3be234758a7c7 (diff) | |
download | rails-d239ac40fa28630a3e683caf28d71bdbfb921ba0.tar.gz rails-d239ac40fa28630a3e683caf28d71bdbfb921ba0.tar.bz2 rails-d239ac40fa28630a3e683caf28d71bdbfb921ba0.zip |
Also accepts Symbols and Classes by calling .to_s on the word supplied
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@366 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/inflector.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activesupport/lib/inflector.rb b/activesupport/lib/inflector.rb index d2fbfb1e7c..f84a45ea7f 100644 --- a/activesupport/lib/inflector.rb +++ b/activesupport/lib/inflector.rb @@ -4,7 +4,7 @@ module Inflector extend self def pluralize(word) - result = word.dup + result = word.to_s.dup plural_rules.each do |(rule, replacement)| break if result.gsub!(rule, replacement) end @@ -12,7 +12,7 @@ module Inflector end def singularize(word) - result = word.dup + result = word.to_s.dup singular_rules.each do |(rule, replacement)| break if result.gsub!(rule, replacement) end @@ -20,15 +20,15 @@ module Inflector end def camelize(lower_case_and_underscored_word) - lower_case_and_underscored_word.gsub(/(^|_)(.)/){$2.upcase} + lower_case_and_underscored_word.to_s.gsub(/(^|_)(.)/){$2.upcase} end def underscore(camel_cased_word) - camel_cased_word.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase + camel_cased_word.to_s.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase end def demodulize(class_name_in_module) - class_name_in_module.gsub(/^.*::/, '') + class_name_in_module.to_s.gsub(/^.*::/, '') end def tableize(class_name) |