mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Implement UnboundMethod#duplicable?
This commit is contained in:
parent
59f450500c
commit
71476313e0
2 changed files with 11 additions and 2 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
#--
|
#--
|
||||||
|
@ -38,3 +37,13 @@ class Method
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class UnboundMethod
|
||||||
|
# Unbound methods are not duplicable:
|
||||||
|
#
|
||||||
|
# method(:puts).unbind.duplicable? # => false
|
||||||
|
# method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
|
||||||
|
def duplicable?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ require "active_support/core_ext/object/duplicable"
|
||||||
require "active_support/core_ext/numeric/time"
|
require "active_support/core_ext/numeric/time"
|
||||||
|
|
||||||
class DuplicableTest < ActiveSupport::TestCase
|
class DuplicableTest < ActiveSupport::TestCase
|
||||||
RAISE_DUP = [method(:puts)]
|
RAISE_DUP = [method(:puts), method(:puts).unbind]
|
||||||
ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal("4.56"), nil, false, true, 1, 2.3, Complex(1), Rational(1)]
|
ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal("4.56"), nil, false, true, 1, 2.3, Complex(1), Rational(1)]
|
||||||
|
|
||||||
def test_duplicable
|
def test_duplicable
|
||||||
|
|
Loading…
Reference in a new issue