From 71476313e0f94b7887bcb7aad3956c0d62505f4c Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 11 Jul 2019 17:39:19 +0200 Subject: Implement UnboundMethod#duplicable? --- .../lib/active_support/core_ext/object/duplicable.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb index 265bb7bf48..3ebcdca02b 100644 --- a/activesupport/lib/active_support/core_ext/object/duplicable.rb +++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true #-- @@ -38,3 +37,13 @@ class Method false 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 -- cgit v1.2.3