diff config/initializers/10-patches.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents 261b3d9a4903
children
line wrap: on
line diff
--- a/config/initializers/10-patches.rb	Tue Sep 09 09:28:31 2014 +0100
+++ b/config/initializers/10-patches.rb	Tue Sep 09 09:29:00 2014 +0100
@@ -202,3 +202,59 @@
     end
   end
 end
+
+if Rails::VERSION::MAJOR < 4 && RUBY_VERSION >= "2.1"
+  module ActiveSupport
+    class HashWithIndifferentAccess
+      def select(*args, &block)
+        dup.tap { |hash| hash.select!(*args, &block) }
+      end
+
+      def reject(*args, &block)
+        dup.tap { |hash| hash.reject!(*args, &block) }
+      end
+    end
+
+    class OrderedHash
+      def select(*args, &block)
+        dup.tap { |hash| hash.select!(*args, &block) }
+      end
+
+      def reject(*args, &block)
+        dup.tap { |hash| hash.reject!(*args, &block) }
+      end
+    end
+  end
+end
+
+require 'awesome_nested_set/version'
+
+module CollectiveIdea
+  module Acts
+    module NestedSet
+      module Model
+        def leaf_with_new_record?
+          new_record? || leaf_without_new_record?
+        end
+        alias_method_chain :leaf?, :new_record
+        # Reload is needed because children may have updated
+        # their parent (self) during deletion.
+        if ::AwesomeNestedSet::VERSION > "2.1.6"
+          module Prunable
+            def destroy_descendants_with_reload
+              destroy_descendants_without_reload
+              reload
+            end
+            alias_method_chain :destroy_descendants, :reload
+          end
+        else
+          def destroy_descendants_with_reload
+            destroy_descendants_without_reload
+            reload
+          end
+          alias_method_chain :destroy_descendants, :reload
+        end
+      end
+    end
+  end
+end