From 8033d3370c56d8d69673c000182922228504706c Mon Sep 17 00:00:00 2001 From: Dmitriy Kiriyenko Date: Tue, 26 Nov 2013 17:03:25 +0200 Subject: Fix segmentation fault in Ruby 2.0.0-p353. In Ruby 2.0.0-p353 there was a [commit](https://github.com/ruby/ruby/commit/66915c507777c5e3a978fa73de25db763efd9206) that switched case matching from actual sending `===` method to magic lookup, that does not see it in `method_missing`. It's hard to predict how exactly and when exactly this bug will be solved so here I suggest a solution of defining it in Duration directly. In Ruby 2.0.0-p353 without the added fix added test crashes to segmentation fault. --- activesupport/lib/active_support/duration.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 87b6407038..7df4857c25 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -99,6 +99,14 @@ module ActiveSupport private + # We define it as a workaround to Ruby 2.0.0-p353 bug. + # For more information, check rails/rails#13055. + # It should be dropped once a new Ruby patch-level + # release after 2.0.0-p353 happens. + def ===(other) #:nodoc: + value === other + end + def method_missing(method, *args, &block) #:nodoc: value.send(method, *args, &block) end -- cgit v1.2.3