Class: Ansr::Blacklight::Solr::Response
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- Ansr::Blacklight::Solr::Response
show all
- Includes:
- PaginationMethods
- Defined in:
- lib/ansr_blacklight/solr/response.rb
Overview
copied directly from Blacklight::SolrResponse
Defined Under Namespace
Modules: InternalResponse
Instance Attribute Summary collapse
Instance Method Summary
collapse
#limit_value, #model_name, #next_page, #offset_value, #prev_page, #total_count
Constructor Details
#initialize(data, request_params) ⇒ Response
Returns a new instance of Response.
14
15
16
17
18
19
20
21
|
# File 'lib/ansr_blacklight/solr/response.rb', line 14
def initialize(data, request_params)
super(data)
@request_params = request_params
extend Spelling
extend Ansr::Facets
extend InternalResponse
extend MoreLikeThis
end
|
Instance Attribute Details
#request_params ⇒ Object
Returns the value of attribute request_params.
13
14
15
|
# File 'lib/ansr_blacklight/solr/response.rb', line 13
def request_params
@request_params
end
|
Instance Method Details
#docs ⇒ Object
40
41
42
43
44
|
# File 'lib/ansr_blacklight/solr/response.rb', line 40
def docs
@docs ||= begin
response['docs'] || []
end
end
|
#group(key, model) ⇒ Object
67
68
69
|
# File 'lib/ansr_blacklight/solr/response.rb', line 67
def group key, model
grouped(model).select { |x| x.key == key }.first
end
|
#grouped(model) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ansr_blacklight/solr/response.rb', line 50
def grouped(model)
@groups ||= self["grouped"].map do |field, group|
if group["groups"] GroupResponse.new field, model, group, self
else Group.new({field => field}, model, group, self)
end
end
end
|
#grouped? ⇒ Boolean
71
72
73
|
# File 'lib/ansr_blacklight/solr/response.rb', line 71
def grouped?
self.has_key? "grouped"
end
|
23
24
25
|
# File 'lib/ansr_blacklight/solr/response.rb', line 23
def
self['responseHeader']
end
|
#params ⇒ Object
32
33
34
|
# File 'lib/ansr_blacklight/solr/response.rb', line 32
def params
( and ['params']) ? ['params'] : request_params
end
|
#rows ⇒ Object
36
37
38
|
# File 'lib/ansr_blacklight/solr/response.rb', line 36
def rows
params[:rows].to_i
end
|
#spelling ⇒ Object
46
47
48
|
# File 'lib/ansr_blacklight/solr/response.rb', line 46
def spelling
self['spelling']
end
|
#update(other_hash) ⇒ Object
27
28
29
30
|
# File 'lib/ansr_blacklight/solr/response.rb', line 27
def update(other_hash)
other_hash.each_pair { |key, value| self[key] = value }
self
end
|