Class: Droonga::Catalog::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/catalog/fetcher.rb

Defined Under Namespace

Classes: EmptyCatalog, EmptyResponse

Instance Method Summary collapse

Constructor Details

#initialize(client_options) ⇒ Fetcher

Returns a new instance of Fetcher.



32
33
34
# File 'lib/droonga/catalog/fetcher.rb', line 32

def initialize(client_options)
  @client_options = default_options.merge(client_options)
end

Instance Method Details

#fetch(options = {}) ⇒ Object

Raises:



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/droonga/catalog/fetcher.rb', line 36

def fetch(options={})
  message = {
    "dataset" => options[:dataset] || Catalog::Dataset::DEFAULT_NAME,
    "type"    => "catalog.fetch"
  }
  response = nil
  Droonga::Client.open(@client_options) do |client|
    response = client.request(message)
  end
  raise EmptyResponse.new unless response
  raise EmptyCatalog.new unless response["body"]
  response["body"]
end