Sha256: e916bfeb7d2c903e5582ceefda1d3c21da33f4559b4cc9a250e4c35b761f1765

Contents?: true

Size: 1.49 KB

Versions: 58

Compression:

Stored size: 1.49 KB

Contents

# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class Solr::Response::Ruby < Solr::Response::Base
  attr_reader :data, :header

  def initialize(ruby_code)
    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 = eval(ruby_code)
      @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 ruby code: #{e}")
    end
  end

  def ok?
    @header['status'] == 0
  end

  def query_time
    @header['QTime']
  end
  
end

Version data entries

58 entries across 58 versions & 12 rubygems

Version Path
zigexn_solr-ruby-0.0.3 lib/solr/response/ruby.rb
zigexn_solr-ruby-0.0.2 lib/solr/response/ruby.rb
zigexn_solr-ruby-0.0.1 lib/solr/response/ruby.rb
greglu-solr-ruby-0.0.7 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.1.0 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.2.0 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.2.1 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.2.2 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.2.3 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.2.4 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.2.5 lib/solr/response/ruby.rb
honkster-acts_as_solr-0.3.4 lib/solr/response/ruby.rb
jbasdf-acts_as_solr-0.3.3 lib/solr/response/ruby.rb
jbasdf-jbasdf-acts_as_solr-0.4.0 lib/solr/response/ruby.rb
jbasdf-muck-solr-0.4.0 lib/solr/response/ruby.rb
jbasdf-muck-solr-0.4.1 lib/solr/response/ruby.rb
jbasdf-muck-solr-0.4.2 lib/solr/response/ruby.rb
onemorecloud-websolr-rails-1.1.1 lib/solr/response/ruby.rb
onemorecloud-websolr-rails-1.3.3 lib/solr/response/ruby.rb
onemorecloud-websolr-rails-1.4.0 lib/solr/response/ruby.rb