Skip to content
Browse files

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
  • Loading branch information...
1 parent 38e55ba commit d239ac40fa28630a3e683caf28d71bdbfb921ba0 @dhh dhh committed Jan 10, 2005
Showing with 5 additions and 5 deletions.
  1. +5 −5 activesupport/lib/inflector.rb
View
10 activesupport/lib/inflector.rb
@@ -4,31 +4,31 @@ 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
return result
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
return result
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)

0 comments on commit d239ac4

Please sign in to comment.
Something went wrong with that request. Please try again.