[Groonga-commit] droonga/fluent-plugin-droonga at e94f3e7 [master] Validate message type for handlers

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Feb 20 16:57:20 JST 2014


YUKI Hiroshi	2014-02-20 16:57:20 +0900 (Thu, 20 Feb 2014)

  New Revision: e94f3e70c8b82e0346f3f505edfe9bd32f737cf0
  https://github.com/droonga/fluent-plugin-droonga/commit/e94f3e70c8b82e0346f3f505edfe9bd32f737cf0

  Message:
    Validate message type for handlers

  Modified files:
    lib/droonga/plugin/metadata/input_message.rb

  Modified: lib/droonga/plugin/metadata/input_message.rb (+15 -0)
===================================================================
--- lib/droonga/plugin/metadata/input_message.rb    2014-02-20 16:52:32 +0900 (ca18c80)
+++ lib/droonga/plugin/metadata/input_message.rb    2014-02-20 16:57:20 +0900 (769220c)
@@ -17,6 +17,19 @@ module Droonga
   module Plugin
     module Metadata
       class InputMessage
+        class NotStringMessageType < Error
+          def initialize(type)
+            super("You must specify a string as a message type. " +
+                    "#{type.inspect} is not a string.")
+          end
+        end
+
+        class BlankMessageType < Error
+          def initialize
+            super("You must specify a non-empty string as a message type.")
+          end
+        end
+
         def initialize(plugin_class)
           @plugin_class = plugin_class
         end
@@ -26,6 +39,8 @@ module Droonga
         end
 
         def type=(type)
+          raise NotStringMessageType.new(type) unless type.is_a?(String)
+          raise BlankMessageType.new if type.empty?
           configuration[:type] = type
         end
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index