Sfoglia il codice sorgente

Rework #770 to properly fix #749

The receiver for the const_defined?() was incorrect, and modifying the
whole line would render the definition of a constant *::Drop to be
omitted when *Drop was already defined.
Akinori MUSHA 10 anni fa
parent
commit
cfe8482c0d
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 6 1
      app/concerns/liquid_droppable.rb

+ 6 - 1
app/concerns/liquid_droppable.rb

@@ -21,7 +21,12 @@ module LiquidDroppable
   end
 
   included do
-    const_set :Drop, Kernel.const_set("#{name}Drop", Class.new(Drop)) unless const_defined?("#{name}Drop")
+    const_set :Drop,
+              if Kernel.const_defined?(drop_name = "#{name}Drop")
+                Kernel.const_get(drop_name)
+              else
+                Kernel.const_set(drop_name, Class.new(Drop))
+              end
   end
 
   def to_liquid