Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added docs for to_proc

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4132 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 484e1c65d8710faeb9f08d33898dc329683b4dab 1 parent 1fcc608
David Heinemeier Hansson dhh authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 activesupport/lib/active_support/core_ext/symbol.rb
9 activesupport/lib/active_support/core_ext/symbol.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.