Sha256: 746986cc40b48dd7091d53cfe17d2fa2dcdb6c357efa72a3d1e790df352450f7

Contents?: true

Size: 564 Bytes

Versions: 1

Compression:

Stored size: 564 Bytes

Contents

unless :to_proc.respond_to?(:to_proc)
  class Symbol
    # Turns the symbol into a simple 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)
    #
    # Returns a Proc which incapsulates the method business logic.
    def to_proc
      Proc.new { |*args| args.shift.__send__(self, *args) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whois-1.1.3 lib/core_ext.rb