diff options
author | Xavier Noria <fxn@hashref.com> | 2011-06-24 14:19:42 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-06-24 14:19:42 -0700 |
commit | 370b380306e03afdf77f29005f33b90a174592f0 (patch) | |
tree | d31280f05051630f66a28067a572f1b4ef5021ac /railties/guides/source/active_support_core_extensions.textile | |
parent | d446c798a5ef6c253c56d3b6a607073a8a92dcf2 (diff) | |
parent | d38ca78dbd99be11e64652163924e9456a7a2362 (diff) | |
download | rails-370b380306e03afdf77f29005f33b90a174592f0.tar.gz rails-370b380306e03afdf77f29005f33b90a174592f0.tar.bz2 rails-370b380306e03afdf77f29005f33b90a174592f0.zip |
Merge pull request #1648 from dlee/acronyms
Inflector support for acronyms (Issue #1366)
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-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 7f33cc4df5..bbf5af5dcc 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1496,7 +1496,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+. |