aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorutilum <oz@utilum.com>2016-12-21 17:41:36 +0100
committerutilum <oz@utilum.com>2016-12-21 17:50:14 +0100
commit83d3b0dbf17582401eb549c4a30f03ecbbfd1a88 (patch)
treebd80970beca75f714c1cad7dbf64027956eedfe6 /activesupport/lib/active_support
parentcb029207e19f511cb7b32c0819acb10dbaeb1198 (diff)
downloadrails-83d3b0dbf17582401eb549c4a30f03ecbbfd1a88.tar.gz
rails-83d3b0dbf17582401eb549c4a30f03ecbbfd1a88.tar.bz2
rails-83d3b0dbf17582401eb549c4a30f03ecbbfd1a88.zip
Fix Complex and Rational are duplicable?
See [this test](https://gist.github.com/utilum/78918f1b64f8b61ee732cb266db7c43a).
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/object/duplicable.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb
index ebe31b38ca..c671d34673 100644
--- a/activesupport/lib/active_support/core_ext/object/duplicable.rb
+++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb
@@ -121,3 +121,23 @@ class Method
false
end
end
+
+class Complex
+ # Complexes are not duplicable:
+ #
+ # Complex(1).duplicable? # => false
+ # Complex(1).dup # => TypeError: can't copy Complex
+ def duplicable?
+ false
+ end
+end
+
+class Rational
+ # Rationals are not duplicable:
+ #
+ # Rational(1).duplicable? # => false
+ # Rational(1).dup # => TypeError: can't copy Rational
+ def duplicable?
+ false
+ end
+end