Class: Droonga::Plugins::CRUD::Adapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/droonga/plugins/crud.rb

Instance Method Summary collapse

Methods inherited from Adapter

id, input_message, output_message

Methods included from Droonga::Pluggable

#find_sub_classes, #options

Instance Method Details

#adapt_input(input_message) ⇒ Object



31
32
33
34
35
36
# File 'lib/droonga/plugins/crud.rb', line 31

def adapt_input(input_message)
  request = input_message.body
  key = request["key"] || rand.to_s
  values = request["values"] || {}
  request["filter"] = values.merge("_key" => key)
end

#adapt_output(output_message) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/droonga/plugins/crud.rb', line 38

def adapt_output(output_message)
  if output_message.errors
    detail = output_message.body["detail"]
    return if detail.nil?
    detail.delete("filter")
    output_message.errors.each do |path, error|
      error["body"]["detail"].delete("filter")
    end
  else
    output_message.body.delete("filter")
  end
end