Navigation Menu

Skip to content

Commit

Permalink
Allow to disable validation by ":validation" option
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 16, 2015
1 parent 4f58bd9 commit 1b160d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/droonga/client.rb
Expand Up @@ -62,27 +62,31 @@ def open(options={})
# @option options [Integer] :timeout (5)
# The timeout value for connecting to, writing to and reading
# from Droonga Engine.
# @option options [Boolean] :validation (true)
# Do or do not validate input messages.
def initialize(options={})
@connection = create_connection(options)
@completer = MessageCompleter.new
@validator = MessageValidator.new
unless options[:validation] == false
@validator = MessageValidator.new
end
end

def send(message, options={}, &block)
message = @completer.complete(message)
@validator.validate(message)
@validator.validate(message) if @validator
@connection.send(message, options, &block)
end

def request(message, options={}, &block)
message = @completer.complete(message)
@validator.validate(message)
@validator.validate(message) if @validator
@connection.request(message, options, &block)
end

def subscribe(message, options={}, &block)
message = @completer.complete(message)
@validator.validate(message)
@validator.validate(message) if @validator
@connection.subscribe(message, options, &block)
end

Expand Down

0 comments on commit 1b160d4

Please sign in to comment.