From 0f0e42448a20e5e51164fdf5265fc2d2d43ade6f Mon Sep 17 00:00:00 2001 From: Holger Just Date: Tue, 3 Jan 2012 19:45:38 +0100 Subject: [PATCH] Overwrite compact on child class of Array to not return an instance of Array This is necessary because in Ruby 1.9.3, the behavior of an internal dup of the array (rb_ary_dup) was changed to always return an array instance, not an instance of the actual class which it was working on. Why can't people just stick to what works but instead try to have special snowflakes everywhere? --- lib/redmine/scm/adapters/abstract_adapter.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 6360cc5c..55bcbb70 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -251,6 +251,14 @@ module Redmine def revisions revisions ||= Revisions.new(collect{|entry| entry.lastrev}.compact) end + + # Required since Ruby 1.9.3 as the core compact always returns an + # instance of Array. This method follows the spec for Array#compact + def compact + ary = self.dup + ary.compact! + ary + end end class Info