1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Update CHANGELOG for safe_constantize.

This commit is contained in:
José Valim 2011-09-23 16:49:05 +02:00
parent e8987c30d0
commit 36699977f2
2 changed files with 6 additions and 1 deletions

View file

@ -1,5 +1,7 @@
*Rails 3.2.0 (unreleased)*
* Added safe_constantize that constantizes a string but returns nil instead of an exception if the constant (or part of it) does not exist [Ryan Oblak]
* ActiveSupport::OrderedHash is now marked as extractable when using Array#extract_options! [Prem Sichanugrist]
* Added Array#prepend as an alias for Array#unshift and Array#append as an alias for Array#<< [DHH]

View file

@ -239,10 +239,13 @@ module ActiveSupport
# "C".safe_constantize # => 'outside', same as ::C
# end
#
# nil is returned when the name is not in CamelCase or the constant is
# nil is returned when the name is not in CamelCase or the constant (or part of it) is
# unknown.
#
# "blargle".safe_constantize # => nil
# "UnknownModule".safe_constantize # => nil
# "UnknownModule::Foo::Bar".safe_constantize # => nil
#
def safe_constantize(camel_cased_word)
begin
constantize(camel_cased_word)