class Dbla::Response
Public Class Methods
new(data, request_params, options = {})
click to toggle source
Calls superclass method
# File lib/dbla/response.rb, line 5 def initialize(data, request_params, options = {}) super(force_to_utf8(data)) @request_params = request_params self.document_model = options[:solr_document_model] || options[:document_model] || Item self.blacklight_config = options[:blacklight_config] if data @total = data.fetch('count',0) @documents = (data['docs'] || []).map {|d| document_model.new(d,self)} @start = data.fetch('start',0) @limit = data.fetch('limit',10) @aggregations = (data['facets'] || {}) else @aggregations = {} @total = 0 @start = 0 @limit = 10 @documents = [] end end
Public Instance Methods
aggregations()
click to toggle source
# File lib/dbla/response.rb, line 24 def aggregations # "facets":{"sourceResource.format":{"_type":"terms","missing":77,"total":250,"other":16,"terms":[{"term":"Photographs","count":44}, Hash[@aggregations.map do |k,v| next unless v['terms'] items = v['terms'].map {|term| Facets::FacetItem.new(value: term['term'], hits: term['count'])} [k, Facets::FacetField.new(k,items)] end] end
facet_by_field_name(facet_field)
click to toggle source
# File lib/dbla/response.rb, line 32 def facet_by_field_name(facet_field) aggregations[facet_field.to_s] end
spelling()
click to toggle source
# File lib/dbla/response.rb, line 35 def spelling Words.new([]) end