mirror of
https://github.com/github/rails.git
synced 2026-01-06 21:34:08 -05:00
Remove Proc#bind from Rails 3.2
This commit is contained in:
@@ -2,7 +2,6 @@ require 'mail'
|
||||
require 'action_mailer/collector'
|
||||
require 'active_support/core_ext/array/wrap'
|
||||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/core_ext/proc'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require 'active_support/core_ext/hash/except'
|
||||
require 'active_support/core_ext/module/anonymous'
|
||||
@@ -627,7 +626,7 @@ module ActionMailer #:nodoc:
|
||||
|
||||
# Call all the procs (if any)
|
||||
default_values = self.class.default.merge(self.class.default) do |k,v|
|
||||
v.respond_to?(:call) ? v.bind(self).call : v
|
||||
v.respond_to?(:call) ? instance_eval(&v) : v
|
||||
end
|
||||
|
||||
# Handle defaults
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
require "active_support/core_ext/kernel/singleton_class"
|
||||
|
||||
class Proc #:nodoc:
|
||||
def bind(object)
|
||||
block, time = self, Time.now
|
||||
object.class_eval do
|
||||
method_name = "__bind_#{time.to_i}_#{time.usec}"
|
||||
define_method(method_name, &block)
|
||||
method = instance_method(method_name)
|
||||
remove_method(method_name)
|
||||
method
|
||||
end.bind(object)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
require 'active_support/concern'
|
||||
require 'active_support/core_ext/class/attribute'
|
||||
require 'active_support/core_ext/proc'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require 'active_support/core_ext/array/extract_options'
|
||||
|
||||
@@ -108,7 +107,11 @@ module ActiveSupport
|
||||
when Symbol
|
||||
method(rescuer)
|
||||
when Proc
|
||||
rescuer.bind(self)
|
||||
if rescuer.arity == 0
|
||||
Proc.new { instance_exec(&rescuer) }
|
||||
else
|
||||
Proc.new { |_exception| instance_exec(_exception, &rescuer) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/proc'
|
||||
|
||||
class ProcTests < Test::Unit::TestCase
|
||||
def test_bind_returns_method_with_changed_self
|
||||
block = Proc.new { self }
|
||||
assert_equal self, block.call
|
||||
bound_block = block.bind("hello")
|
||||
assert_not_equal block, bound_block
|
||||
assert_equal "hello", bound_block.call
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user