Class: Droonga::InputAdapter

Inherits:
Object
  • Object
show all
Includes:
Pluggable
Defined in:
lib/droonga/input_adapter.rb

Instance Method Summary collapse

Methods included from Pluggable

#process, #processable?, #shutdown

Constructor Details

#initialize(dispatcher, options = {}) ⇒ InputAdapter

Returns a new instance of InputAdapter.



26
27
28
29
# File 'lib/droonga/input_adapter.rb', line 26

def initialize(dispatcher, options={})
  @dispatcher = dispatcher
  load_plugins(options[:plugins] || [])
end

Instance Method Details

#adapt(message) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/droonga/input_adapter.rb', line 31

def adapt(message)
  adapted_message = message
  @plugins.each do |plugin|
    input_message = InputMessage.new(adapted_message)
    command = input_message.command
    next unless plugin.processable?(command)
    process(command, input_message)
    adapted_message = input_message.adapted_message
  end
  adapted_message
end