diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-02 16:28:30 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-02 16:28:30 +0000 |
commit | 484e1c65d8710faeb9f08d33898dc329683b4dab (patch) | |
tree | d93a6a07affcc792f9ccbd45f826f00e8b2ef68b /activesupport | |
parent | 1fcc60895b9fa9d969649dca46b861fa38263b90 (diff) | |
download | rails-484e1c65d8710faeb9f08d33898dc329683b4dab.tar.gz rails-484e1c65d8710faeb9f08d33898dc329683b4dab.tar.bz2 rails-484e1c65d8710faeb9f08d33898dc329683b4dab.zip |
Added docs for to_proc
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4132 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/symbol.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/symbol.rb b/activesupport/lib/active_support/core_ext/symbol.rb index cd928aae80..434d6abdbb 100644 --- a/activesupport/lib/active_support/core_ext/symbol.rb +++ b/activesupport/lib/active_support/core_ext/symbol.rb @@ -1,4 +1,11 @@ -class Symbol #:nodoc: +class Symbol + # Turns the symbol into a simpel proc, which is especially useful for enumerations. Examples: + # + # # The same as people.collect { |p| p.name } + # people.collect(&:name) + # + # # The same as people.select { |p| p.manager? }.collect { |p| p.salary } + # people.select(&:manager?).collect(&:salary) def to_proc Proc.new { |obj, *args| obj.send(self, *args) } end |