aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2017-03-23 17:34:30 +0530
committerVipul A M <vipulnsward@gmail.com>2017-03-23 17:34:30 +0530
commit7045e03dee2cda9af65bc8e51bddab79599f44cd (patch)
treedc448a96b52288beb2aa14126f97dc0d687639fb /activesupport/lib
parenteb85100426dd49c355bb712759859537c6de9ead (diff)
downloadrails-7045e03dee2cda9af65bc8e51bddab79599f44cd.tar.gz
rails-7045e03dee2cda9af65bc8e51bddab79599f44cd.tar.bz2
rails-7045e03dee2cda9af65bc8e51bddab79599f44cd.zip
Fix duplicable? for Ratiional and Complex on ruby master, since they are now duplicable
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/object/duplicable.rb34
1 files changed, 22 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb
index ea81df2bd8..c27fd4f792 100644
--- a/activesupport/lib/active_support/core_ext/object/duplicable.rb
+++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb
@@ -124,21 +124,31 @@ class Method
end
class Complex
- # Complexes are not duplicable:
- #
- # Complex(1).duplicable? # => false
- # Complex(1).dup # => TypeError: can't copy Complex
- def duplicable?
- false
+ begin
+ Complex(1).dup
+ rescue TypeError
+
+ # Complexes are not duplicable for RUBY_VERSION < 2.5.0:
+ #
+ # Complex(1).duplicable? # => false
+ # Complex(1).dup # => TypeError: can't copy Complex
+ def duplicable?
+ false
+ end
end
end
class Rational
- # Rationals are not duplicable:
- #
- # Rational(1).duplicable? # => false
- # Rational(1).dup # => TypeError: can't copy Rational
- def duplicable?
- false
+ begin
+ Rational(1).dup
+ rescue TypeError
+
+ # Rationals are not duplicable for RUBY_VERSION < 2.5.0:
+ #
+ # Rational(1).duplicable? # => false
+ # Rational(1).dup # => TypeError: can't copy Rational
+ def duplicable?
+ false
+ end
end
end