diff options
author | David Lee <davidomundo@gmail.com> | 2011-06-09 01:10:49 -0700 |
---|---|---|
committer | David Lee <davidomundo@gmail.com> | 2011-06-11 01:43:24 -0700 |
commit | d38ca78dbd99be11e64652163924e9456a7a2362 (patch) | |
tree | 59da59dcc96a82845d9f735b117cbfc4f38d2c54 /railties/guides/source | |
parent | 51cd6bb829c418c5fbf75de1dfbb177233b1b154 (diff) | |
download | rails-d38ca78dbd99be11e64652163924e9456a7a2362.tar.gz rails-d38ca78dbd99be11e64652163924e9456a7a2362.tar.bz2 rails-d38ca78dbd99be11e64652163924e9456a7a2362.zip |
Add acronym support to Inflector; Issue #1366
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 7512f7bcb9..3616e3385c 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1460,7 +1460,15 @@ end That may be handy to compute method names in a language that follows that convention, for example JavaScript. -INFO: As a rule of thumb you can think of +camelize+ as the inverse of +underscore+, though there are cases where that does not hold: <tt>"SSLError".underscore.camelize</tt> gives back <tt>"SslError"</tt>. +INFO: As a rule of thumb you can think of +camelize+ as the inverse of +underscore+, though there are cases where that does not hold: <tt>"SSLError".underscore.camelize</tt> gives back <tt>"SslError"</tt>. To support cases such as this, Active Support allows you to specify acronyms in +config/initializers/inflections.rb+: + +<ruby> +ActiveSupport::Inflector.inflections do |inflect| + inflect.acronym 'SSL' +end + +"SSLError".underscore.camelize #=> "SSLError" +</ruby> +camelize+ is aliased to +camelcase+. |