Class: Solr::Response::Ruby

Inherits:
Base
  • Object
show all
Defined in:
lib/solr_ruby_support.rb

Overview

FIXME. I should create Solr::Response::JavaBin class,

but response class hierarchy doesn't permit it ! (kennyj)

Instance Method Summary collapse

Constructor Details

#initialize(java_bin_data) ⇒ Ruby

Returns a new instance of Ruby.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/solr_ruby_support.rb', line 73

def initialize(java_bin_data)
  super
  begin
    #TODO: what about pulling up data/header/response to ResponseBase,
    #      or maybe a new middle class like SelectResponseBase since
    #      all Select queries return this same sort of stuff??
    #      XML (&wt=xml) and Ruby (&wt=ruby) responses contain exactly the same structure.
    #      a goal of solrb is to make it irrelevant which gets used under the hood, 
    #      but favor Ruby responses.
    @data = ::JavaBin.parser.new.parse(java_bin_data)
    @header = @data['responseHeader']
    raise "response should be a hash" unless @data.kind_of? Hash
    raise "response header missing" unless @header.kind_of? Hash
  rescue SyntaxError => e
    raise Solr::Exception.new("invalid java bin data: #{e}")
  end
end