Class: Solr::Request::Custom
- Defined in:
- lib/solr/request/custom.rb
Overview
“Abstract” base class, only useful with subclasses that add parameters
Instance Attribute Summary
Attributes inherited from Select
Instance Method Summary collapse
- #content_type ⇒ Object
- #handler ⇒ Object
-
#initialize(qt = nil, params = {}, content_type = 'application/x-www-form-urlencoded; charset=utf-8') ⇒ Custom
constructor
A new instance of Custom.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods inherited from Select
Methods inherited from Base
Constructor Details
#initialize(qt = nil, params = {}, content_type = 'application/x-www-form-urlencoded; charset=utf-8') ⇒ Custom
Returns a new instance of Custom.
18 19 20 21 |
# File 'lib/solr/request/custom.rb', line 18 def initialize(qt=nil, params={}, content_type='application/x-www-form-urlencoded; charset=utf-8') super(qt,params) @content_type = content_type end |
Instance Method Details
#content_type ⇒ Object
27 28 29 |
# File 'lib/solr/request/custom.rb', line 27 def content_type @content_type end |
#handler ⇒ Object
23 24 25 |
# File 'lib/solr/request/custom.rb', line 23 def handler @query_type.starts_with('/') ? qt.remove_first('/') : 'select' end |
#to_hash ⇒ Object
31 32 33 |
# File 'lib/solr/request/custom.rb', line 31 def to_hash return {:qt => query_type, :wt => 'ruby'}.merge(@select_params) end |
#to_s ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/solr/request/custom.rb', line 35 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 |