A mixin module for RSolr::Client -- note, this must mixed-in via "extend" on a RSolr::Client instance.
Just like RSolr::Client build_request but converts the page and per_page arguments into :rows and :start.
# File lib/rsolr/pagination.rb, line 31 def build_paginated_request page, per_page, path, opts = nil opts ||= {} opts[:page] = page opts[:per_page] = per_page opts[:params] ||= {} values = RSolr::Pagination.calculate_start_and_rows(page, per_page) opts[:params][:start] = values[0] opts[:params][:rows] = values[1] build_request path, opts end
A paginated request method.
# File lib/rsolr/pagination.rb, line 19 def paginate page, per_page, path, opts = nil @warned ||= begin warn "DEPRECATION WARNING: RSolr::Pagination / pagination functionality will be removed in 1.1.0." true end request_context = build_paginated_request page, per_page, path, opts execute request_context end
Overrides the RSolr::Client evaluate_ruby_response method. Calls the original/super RSolr::Client evaluate_ruby_response method. Mixes in the PaginatedDocSet if the request and request opts are set.
# File lib/rsolr/pagination.rb, line 68 def evaluate_ruby_response request, response result = super request, response if request[:page] && request[:per_page] && result["response"] && result["response"]["docs"] d = result['response']['docs'].extend PaginatedDocSet d.per_page = request[:per_page] d.start = request[:params][:start] d.total = result["response"]["numFound"].to_s.to_i end result end
Checks if the called method starts with "paginate_*" and converts the * to the solr request path. It then calls paginate with the appropriate arguments. If the called method doesn't start with "paginate_", the original/super RSolr::Client method_missing method is called.
# File lib/rsolr/pagination.rb, line 54 def method_missing name, *args if name.to_s =~ /^paginated?_(.+)$/ paginate args[0], args[1], $1, *args[2..-1] else super name, *args end end
Generated with the Darkfish Rdoc Generator 2.