Class: Solr::Request
- Inherits:
-
Object
- Object
- Solr::Request
- Defined in:
- lib/solr-client.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #data ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(url, data = nil, &block) ⇒ Request
constructor
A new instance of Request.
- #on_complete(curl) ⇒ Object
- #response ⇒ Object
- #success? ⇒ Boolean
- #sync? ⇒ Boolean
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
67 68 69 |
# File 'lib/solr-client.rb', line 67 def body @body end |
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
67 68 69 |
# File 'lib/solr-client.rb', line 67 def callback @callback end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
67 68 69 |
# File 'lib/solr-client.rb', line 67 def url @url end |
Instance Method Details
#data ⇒ Object
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
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 |
#response ⇒ Object
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
97 98 99 |
# File 'lib/solr-client.rb', line 97 def success? @code == 200 end |
#sync? ⇒ Boolean
75 76 77 |
# File 'lib/solr-client.rb', line 75 def sync? @callback.nil? end |