Class: Droonga::OutputAdapter

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

Instance Method Summary collapse

Methods included from Pluggable

#process, #processable?, #shutdown

Constructor Details

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

Returns a new instance of OutputAdapter.



26
27
28
29
# File 'lib/droonga/output_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
42
# File 'lib/droonga/output_adapter.rb', line 31

def adapt(message)
  adapted_message = message
  message["via"].reverse_each do |command|
    @plugins.each do |plugin|
      next unless plugin.processable?(command)
      output_message = OutputMessage.new(adapted_message)
      process(command, output_message)
      adapted_message = output_message.adapted_message
    end
  end
  adapted_message
end