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
abiquo-etk-0.4.33 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.32 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.29 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.25 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.24 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.23 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.22 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.20 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.19 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.18 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.17 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.16 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.15 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.14 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
abiquo-etk-0.4.13 vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb
activesupport-2.3.10 lib/active_support/core_ext/symbol.rb
activesupport-2.3.9 lib/active_support/core_ext/symbol.rb
activesupport-2.3.9.pre lib/active_support/core_ext/symbol.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb