Sha256: 8ad6047abf64df7b2c9470bfe580511e616e106074c823c7d9f7eda876de6e6c

Contents?: true

Size: 472 Bytes

Versions: 201

Compression:

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

Version data entries

201 entries across 168 versions & 25 rubygems

Version Path
whois-1.0.6 lib/core_ext.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.3.3/lib/active_support/core_ext/symbol.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
activesupport-2.3.6.pre lib/active_support/core_ext/symbol.rb
whois-1.0.5 lib/core_ext.rb
whois-1.0.4 lib/core_ext.rb
simply_stated-0.0.5 vendor/gems/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/symbol.rb
simply_stated-0.0.4 vendor/gems/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/symbol.rb
factorylabs-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/symbol.rb
ginst-2009.12.8 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
activesupport-2.3.5 lib/active_support/core_ext/symbol.rb
ginst-2009.11.24 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
ginst-2009.11.23 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
ginst-2.0.1 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
ginst-2.0.0 vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
gemstreamer-1.2.0 spec/assets/testapp/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
gemstreamer-1.1.1 spec/assets/testapp/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
gemstreamer-1.1.0 spec/assets/testapp/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb