mirror of
https://github.com/apache/lucene.git
synced 2025-02-10 03:55:46 +00:00
8b963995a0
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@496871 13f79535-47bb-0310-9956-ffa450edef68
33 lines
761 B
Ruby
33 lines
761 B
Ruby
module Solr
|
|
module Response
|
|
|
|
class Ruby < Solr::Response::Base
|
|
attr_reader :data
|
|
|
|
def initialize(ruby_code)
|
|
super(ruby_code)
|
|
begin
|
|
@data = eval(ruby_code)
|
|
@header = @data['responseHeader']
|
|
@response = @data['response']
|
|
raise "response should be a hash" unless @data.kind_of? Hash
|
|
raise "response header missing" unless @header.kind_of? Hash
|
|
raise "response section missing" unless @response.kind_of? Hash
|
|
rescue Exception => e
|
|
raise Solr::Exception.new("invalid ruby code: #{e}")
|
|
end
|
|
end
|
|
|
|
def ok?
|
|
return @header['status'] == 0
|
|
end
|
|
|
|
def query_time
|
|
return @header['QTime']
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|