Class: SolrMakr::SolrAPI::RequestParams
- Inherits:
-
Object
- Object
- SolrMakr::SolrAPI::RequestParams
- Defined in:
- lib/solr_makr/solr_api/request_params.rb
Overview
Wrapper around parameters passed to solr api requests.
Solr requests are not really RESTful, and instead take the action name in a parameter on the query string.
Instance Attribute Summary collapse
-
#action ⇒ String
readonly
The name of the solr action, which is automatically applied to the query string parameters when the request is made.
- #params ⇒ ActiveSupport::HashWithIndifferentAccess readonly private
- #query ⇒ ActiveSupport::HashWithIndifferentAccess readonly
Instance Method Summary collapse
-
#body(request_body) ⇒ void
Set the body for the request.
-
#initialize(action:) ⇒ RequestParams
constructor
A new instance of RequestParams.
- #to_h(options = nil) ⇒ Object (also: #to_hash, #as_json)
Constructor Details
#initialize(action:) ⇒ RequestParams
Returns a new instance of RequestParams.
9 10 11 12 13 |
# File 'lib/solr_makr/solr_api/request_params.rb', line 9 def initialize(action:) @action = action @query = {}.with_indifferent_access @params = {}.with_indifferent_access end |
Instance Attribute Details
#action ⇒ String (readonly)
The name of the solr action, which is automatically applied to the query string parameters when the request is made.
19 20 21 |
# File 'lib/solr_makr/solr_api/request_params.rb', line 19 def action @action end |
#params ⇒ ActiveSupport::HashWithIndifferentAccess (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/solr_makr/solr_api/request_params.rb', line 24 def params @params end |
#query ⇒ ActiveSupport::HashWithIndifferentAccess (readonly)
28 29 30 |
# File 'lib/solr_makr/solr_api/request_params.rb', line 28 def query @query end |
Instance Method Details
#body(request_body) ⇒ void
This method returns an undefined value.
Set the body for the request.
36 37 38 |
# File 'lib/solr_makr/solr_api/request_params.rb', line 36 def body(request_body) @params[:body] = request_body end |
#to_h(options = nil) ⇒ Object Also known as: to_hash, as_json
40 41 42 43 44 |
# File 'lib/solr_makr/solr_api/request_params.rb', line 40 def to_h( = nil) query[:action] = @action @params.to_h.merge(query: query) end |