提交 1979e9c8 编写于 作者: X Xavier Noria

Symbol#to_proc is not needed for Ruby >= 1.8.7

上级 d4513ac6
require 'abstract_unit'
require 'active_support/core_ext/symbol'
class ActionController::Base
class << self
......
......@@ -12,7 +12,6 @@
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/string/behavior'
require 'active_support/core_ext/symbol'
require 'active_support/core_ext/object/metaclass'
module ActiveRecord #:nodoc:
......
require 'abstract_unit'
require "fixtures/person"
require "fixtures/street_address"
require 'active_support/core_ext/symbol'
require 'active_support/core_ext/hash/conversions'
module Highrise
......
require 'active_support/core_ext/symbol/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)
#
# This is a builtin method in Ruby 1.8.7 and later.
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end unless :to_proc.respond_to?(:to_proc)
end
......@@ -9,7 +9,6 @@
# Process Process.daemon
# REXML security fix
# String ord
# Symbol to_proc
# Time to_date, to_time, to_datetime
require 'active_support'
require 'active_support/core_ext/date/calculations'
......@@ -20,5 +19,4 @@
require 'active_support/core_ext/process/daemon'
require 'active_support/core_ext/string/conversions'
require 'active_support/core_ext/rexml'
require 'active_support/core_ext/symbol/to_proc'
require 'active_support/core_ext/time/conversions'
require 'abstract_unit'
require 'active_support/core_ext/array'
require 'active_support/core_ext/symbol'
require 'active_support/core_ext/enumerable'
Payment = Struct.new(:price)
......
require 'abstract_unit'
class SymbolTests < Test::Unit::TestCase
def test_to_proc
assert_equal %w(one two three), [:one, :two, :three].map(&:to_s)
assert_equal(%w(one two three),
{1 => "one", 2 => "two", 3 => "three"}.sort_by(&:first).map(&:last))
end
end
......@@ -3,7 +3,6 @@
require 'active_support/dependencies'
require 'active_support/core_ext/module/loading'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/symbol/to_proc'
module ModuleWithMissing
mattr_accessor :missing_count
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册