diff options
author | Jamis Buck <jamis@37signals.com> | 2006-03-15 21:05:10 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-03-15 21:05:10 +0000 |
commit | 6c95e9b14697a9527ab761d1a084f6bc61af56b9 (patch) | |
tree | f22570b4789e922f9605e5c5d52eaa4e04ad93b4 /activesupport/lib | |
parent | 6480d4974920ba3a22606770b49cb4140fa3ad40 (diff) | |
download | rails-6c95e9b14697a9527ab761d1a084f6bc61af56b9.tar.gz rails-6c95e9b14697a9527ab761d1a084f6bc61af56b9.tar.bz2 rails-6c95e9b14697a9527ab761d1a084f6bc61af56b9.zip |
Enhance Inflector.underscore to convert '-' into '_' (as the inverse of Inflector.dasherize)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3877 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/inflector.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index bbc5e10579..43620757c2 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -118,7 +118,11 @@ module Inflector end def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase + camel_cased_word.to_s.gsub(/::/, '/'). + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + tr("-", "_"). + downcase end def dasherize(underscored_word) |