Class: Solr::Request::Select
- Inherits:
-
Base
- Object
- Base
- Solr::Request::Select
show all
- Defined in:
- lib/solr/request/select.rb
Overview
“Abstract” base class, only useful with subclasses that add parameters
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(qt = nil, params = {}) ⇒ Select
Returns a new instance of Select.
20
21
22
23
|
# File 'lib/solr/request/select.rb', line 20
def initialize(qt=nil, params={})
@query_type = qt
@select_params = params
end
|
Instance Attribute Details
#query_type ⇒ Object
Returns the value of attribute query_type.
18
19
20
|
# File 'lib/solr/request/select.rb', line 18
def query_type
@query_type
end
|
Instance Method Details
#content_type ⇒ Object
33
34
35
|
# File 'lib/solr/request/select.rb', line 33
def content_type
'application/x-www-form-urlencoded; charset=utf-8'
end
|
#handler ⇒ Object
29
30
31
|
# File 'lib/solr/request/select.rb', line 29
def handler
'select'
end
|
25
26
27
|
# File 'lib/solr/request/select.rb', line 25
def response_format
:ruby
end
|
#to_hash ⇒ Object
37
38
39
|
# File 'lib/solr/request/select.rb', line 37
def to_hash
return {:qt => query_type, :wt => 'ruby', :"json.nl" => "map"}.merge(@select_params)
end
|
#to_s ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/solr/request/select.rb', line 41
def to_s
raw_params = self.to_hash
http_params = []
raw_params.each do |key,value|
if value.respond_to? :each
value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" unless v.nil?}
else
http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil?
end
end
http_params.join("&")
end
|