Class: Ansr::Blacklight::Solr::Response::GroupResponse
- Inherits:
-
Object
- Object
- Ansr::Blacklight::Solr::Response::GroupResponse
- Includes:
- PaginationMethods
- Defined in:
- lib/ansr_blacklight/solr/response/group_response.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#key ⇒ Object
(also: #group_field)
readonly
Returns the value of attribute key.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #group_limit ⇒ Object
- #groups ⇒ Object
-
#initialize(key, model, group, response) ⇒ GroupResponse
constructor
A new instance of GroupResponse.
- #method_missing(meth, *args, &block) ⇒ Object
- #respond_to?(meth) ⇒ Boolean
- #start ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(key, model, group, response) ⇒ GroupResponse
Returns a new instance of GroupResponse.
7 8 9 10 11 12 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 7 def initialize key, model, group, response @key = key @model = model @group = group @response = response end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 36 def method_missing meth, *args, &block if response.respond_to? meth response.send(meth, *args, &block) else super end end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 5 def group @group end |
#key ⇒ Object (readonly) Also known as: group_field
Returns the value of attribute key.
5 6 7 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 5 def key @key end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 5 def model @model end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 5 def response @response end |
Instance Method Details
#group_limit ⇒ Object
22 23 24 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 22 def group_limit params.fetch(:'group.limit', 1).to_s.to_i end |
#groups ⇒ Object
16 17 18 19 20 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 16 def groups @groups ||= group["groups"].map do |g| Ansr::Blacklight::Solr::Response::Group.new({key => g[:groupValue]}, model, g, self) end end |
#respond_to?(meth) ⇒ Boolean
46 47 48 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 46 def respond_to? meth response.respond_to?(meth) || super end |
#start ⇒ Object
32 33 34 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 32 def start params[:start].to_s.to_i end |
#total ⇒ Object
26 27 28 29 30 |
# File 'lib/ansr_blacklight/solr/response/group_response.rb', line 26 def total # ngroups is only available in Solr 4.1+ # fall back on the number of facet items for that field? (group["ngroups"] || (response.facet_by_field_name(key) || []).length).to_s.to_i end |