diff options
author | Marcel Molina <marcel@vernix.org> | 2005-11-20 22:36:02 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2005-11-20 22:36:02 +0000 |
commit | 5d785dbc1142aab3b6bb1bc1d0e4d611c7fe45c5 (patch) | |
tree | 414329c2b35a6f42ed040bc41cddfd1e6dbefb38 /activesupport | |
parent | baa2ab5ac30404bce5b5fddaa0d37322280fb48e (diff) | |
download | rails-5d785dbc1142aab3b6bb1bc1d0e4d611c7fe45c5.tar.gz rails-5d785dbc1142aab3b6bb1bc1d0e4d611c7fe45c5.tar.bz2 rails-5d785dbc1142aab3b6bb1bc1d0e4d611c7fe45c5.zip |
Add Array#to_strings which to_s's all elements in an array.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3114 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 4 | ||||
-rw-r--r-- | activesupport/test/core_ext/array_ext_test.rb | 4 |
3 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 0de240ff91..e9611010b7 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add Array#to_strings which to_s's all elements in an array. [Marcel Molina Jr., Sam Stephenson] + * Added the following methods [Marcel Molina Jr., Sam Stephenson]: * Object#copy_instance_variables_from(object) to copy instance variables from one object to another * Object#extended_by to get an instance's included/extended modules diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index e9e9cf445e..28539ac7d6 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -24,6 +24,10 @@ module ActiveSupport #:nodoc: def to_param join '/' end + + def to_strings + map { |element| element.to_s } + end end end end diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 159dc2a478..b07fd9854f 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -33,4 +33,8 @@ class ArrayExtConversionTests < Test::Unit::TestCase def test_one_element assert_equal "one", ['one'].to_sentence end + + def test_to_strings + assert_equal %w(one two three), [:one, :two, :three].to_strings + end end |