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
automate-it-0.9.2 lib/inactive_support/core_ext/symbol.rb
automate-it-0.9.1 lib/inactive_support/core_ext/symbol.rb
automate-it-0.9.0 lib/inactive_support/core_ext/symbol.rb
activesupport-2.0.1 lib/active_support/core_ext/symbol.rb
activesupport-2.0.0 lib/active_support/core_ext/symbol.rb
activesupport-2.0.4 lib/active_support/core_ext/symbol.rb
activesupport-2.0.2 lib/active_support/core_ext/symbol.rb
activesupport-2.0.5 lib/active_support/core_ext/symbol.rb
automateit-0.71230 lib/inactive_support/core_ext/symbol.rb
automateit-0.80116 lib/inactive_support/core_ext/symbol.rb
automateit-0.80624 lib/inactive_support/core_ext/symbol.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/symbol.rb