浏览代码

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 年之前
父节点
当前提交
cfe8482c0d
共有 1 个文件被更改,包括 6 次插入1 次删除
  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