Define Symbol#to_proc for Ruby 1.8.6

Ruby 1.8.6 doesn't have Symbol#to_proc, which allows things like
map(&:to_s) rather than map { |o| o.to_s }. 1.8.7 does, though, and
since it is used in a bunch of the superenv code we should attempt to
keep it compatible with 1.8.6.

Closes Homebrew/homebrew#16046.
This commit is contained in:
Jack Nagel 2013-01-09 17:36:17 -06:00
parent 05772f8ccf
commit 0949d952dc
2 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,5 @@
class Symbol
def to_proc
proc { |obj, *args| obj.send(self, *args) }
end unless method_defined?(:to_proc)
end

View File

@ -2,6 +2,7 @@ require 'extend/fileutils'
require 'extend/pathname'
require 'extend/ARGV'
require 'extend/string'
require 'extend/symbol'
require 'utils'
require 'exceptions'
require 'set'