Navigation Menu

Skip to content

Commit

Permalink
Validate message type for handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 20, 2014
1 parent c06b25b commit e94f3e7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/droonga/plugin/metadata/input_message.rb
Expand Up @@ -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
Expand All @@ -26,6 +39,8 @@ def type
end

def type=(type)
raise NotStringMessageType.new(type) unless type.is_a?(String)
raise BlankMessageType.new if type.empty?
configuration[:type] = type
end

Expand Down

0 comments on commit e94f3e7

Please sign in to comment.