소스 검색

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