Remove deprecated Proc#bind
with no replacement.
This commit is contained in:
parent
1c06bd17a9
commit
f62fb985b6
@ -1,3 +1,7 @@
|
||||
* Remove deprecated `Proc#bind` with no replacement.
|
||||
|
||||
*Carlos Antonio da Silva*
|
||||
|
||||
* Remove deprecated `Array#uniq_by` and `Array#uniq_by!`, use native
|
||||
`Array#uniq` and `Array#uniq!` instead.
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
require "active_support/core_ext/kernel/singleton_class"
|
||||
require "active_support/deprecation"
|
||||
|
||||
class Proc #:nodoc:
|
||||
def bind(object)
|
||||
ActiveSupport::Deprecation.warn 'Proc#bind is deprecated and will be removed in future versions'
|
||||
|
||||
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'
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/proc'
|
||||
|
||||
class ProcTests < ActiveSupport::TestCase
|
||||
def test_bind_returns_method_with_changed_self
|
||||
assert_deprecated do
|
||||
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
|
||||
end
|
Loading…
Reference in New Issue
Block a user