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
3mix-castronaut-0.5.0.2 vendor/activesupport/lib/active_support/core_ext/symbol.rb
masover-castronaut-0.4.4.4 vendor/activesupport/lib/active_support/core_ext/symbol.rb
masover-castronaut-0.4.4.5 vendor/activesupport/lib/active_support/core_ext/symbol.rb
masover-castronaut-0.5.0.1 vendor/activesupport/lib/active_support/core_ext/symbol.rb
p8-castronaut-0.6.1.1 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.4.1 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.4.2 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.4.3 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.4.4 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.4.5 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.4.6 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.5.0 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.5.1 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.5.2 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.5.3 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.5.4 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.6.0 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.6.1 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.7.4 vendor/activesupport/lib/active_support/core_ext/symbol.rb
relevance-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/symbol.rb