diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/symbol.rb | 5 | ||||
-rw-r--r-- | activesupport/test/core_ext/symbol.rb | 8 |
3 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index e9611010b7..6da69d2aae 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.] + * 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]: diff --git a/activesupport/lib/active_support/core_ext/symbol.rb b/activesupport/lib/active_support/core_ext/symbol.rb new file mode 100644 index 0000000000..cd928aae80 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/symbol.rb @@ -0,0 +1,5 @@ +class Symbol #:nodoc: + def to_proc + Proc.new { |obj, *args| obj.send(self, *args) } + end +end diff --git a/activesupport/test/core_ext/symbol.rb b/activesupport/test/core_ext/symbol.rb new file mode 100644 index 0000000000..ae2c585fc2 --- /dev/null +++ b/activesupport/test/core_ext/symbol.rb @@ -0,0 +1,8 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' + +class TestSymbol < Test::Case::TestUnit + def test_to_proc + assert_equal %w(one two three), [:one, :two, :three].map &:to_s + end +end |