diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-06-26 15:40:14 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 20:49:30 +0200 |
commit | 51be8dbdedd1279d74cd7a7e277c5042f278b8a2 (patch) | |
tree | 8199162aec2e4f340b2329fdde4cc7324e01be9d /activesupport/lib/active_support/core_ext/string/inflections.rb | |
parent | df083b482d3f22aebb5e48e608811a740037d2aa (diff) | |
download | rails-51be8dbdedd1279d74cd7a7e277c5042f278b8a2.tar.gz rails-51be8dbdedd1279d74cd7a7e277c5042f278b8a2.tar.bz2 rails-51be8dbdedd1279d74cd7a7e277c5042f278b8a2.zip |
Move constantize from conversions to inflections.
This removes ActiveModel dependency on TZInfo.
[#4979 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string/inflections.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/inflections.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index ef479d559e..66c4034781 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -28,6 +28,17 @@ class String ActiveSupport::Inflector.singularize(self) end + # +constantize+ tries to find a declared constant with the name specified + # in the string. It raises a NameError when the name is not in CamelCase + # or is not initialized. + # + # Examples + # "Module".constantize # => Module + # "Class".constantize # => Class + def constantize + ActiveSupport::Inflector.constantize(self) + end + # By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize # is set to <tt>:lower</tt> then camelize produces lowerCamelCase. # |