root/trunk/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb @ 58

Revision 58, 400 bytes (checked in by dema, 7 years ago)

Updating to Rails 1.1.2

Line 
1class Symbol
2  # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
3  #
4  #   # The same as people.collect { |p| p.name }
5  #   people.collect(&:name)
6  #
7  #   # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
8  #   people.select(&:manager?).collect(&:salary)
9  def to_proc
10    Proc.new { |obj, *args| obj.send(self, *args) }
11  end
12end
Note: See TracBrowser for help on using the browser.