mirror of
https://github.com/github/rails.git
synced 2026-01-29 16:28:09 -05:00
Added docs for to_proc
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4132 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user