Sha256: 7c4f30c974b253655dd2bfae79f7118b4049b9bcda482b2c1539369bb3508a74

Contents?: true

Size: 469 Bytes

Versions: 27

Compression:

Stored size: 469 Bytes

Contents

unless :test.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)
    def to_proc
      Proc.new { |*args| args.shift.__send__(self, *args) }
    end
  end
end

Version data entries

27 entries across 27 versions & 6 rubygems

Version Path
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb
swivel-0.0.160 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb
swivel-0.0.175 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb
swivel-0.0.157 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb