Class: Solr::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/solr-client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, data = nil, &block) ⇒ Request

Returns a new instance of Request.



69
70
71
72
73
# File 'lib/solr-client.rb', line 69

def initialize(url, data = nil, &block)
  @url, @data, @callback = url, data, block
  @success = false
  @finished = false
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



67
68
69
# File 'lib/solr-client.rb', line 67

def body
  @body
end

#callbackObject (readonly)

Returns the value of attribute callback.



67
68
69
# File 'lib/solr-client.rb', line 67

def callback
  @callback
end

#urlObject (readonly)

Returns the value of attribute url.



67
68
69
# File 'lib/solr-client.rb', line 67

def url
  @url
end

Instance Method Details

#dataObject



86
87
88
89
90
91
# File 'lib/solr-client.rb', line 86

def data
  if @data.respond_to?(:call)
    @data = @data.call
  end
  @data
end

#finished?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/solr-client.rb', line 93

def finished?
  @finished
end

#on_complete(curl) ⇒ Object



79
80
81
82
83
84
# File 'lib/solr-client.rb', line 79

def on_complete(curl)
  @finished = true
  @body = curl.body_str
  @code = curl.response_code
  @callback.call(self) if @callback
end

#responseObject



101
102
103
104
# File 'lib/solr-client.rb', line 101

def response
  return @body unless (url =~ /wt=ruby/)
  @response ||= Response.new(@body)
end

#success?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/solr-client.rb', line 97

def success?
  @code == 200
end

#sync?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/solr-client.rb', line 75

def sync?
  @callback.nil?
end