lib/ddr/index/connection.rb in ddr-models-2.4.12 vs lib/ddr/index/connection.rb in ddr-models-2.4.13

- old
+ new

@@ -1,17 +1,36 @@ +require "rsolr" +require "forwardable" + module Ddr::Index - class Connection < SimpleDelegator + # + # Wraps an RSolr connection + # + class Connection - def initialize - super RSolr.connect(ActiveFedora.solr_config) - end + module Methods + extend Forwardable - def select(params, extra={}) - Response.new get("select", params: params.merge(extra)) - end + delegate [:get, :paginate] => :solr - def page(*args) - Response.new paginate(*args) + def solr + RSolr.connect(ActiveFedora.solr_config) + end + + def select(params, extra={}) + Response.new get("select", params: params.merge(extra)) + end + + def page(*args) + Response.new paginate(*args) + end + + def count(params) + select(params, rows: 0).num_found + end end + + extend Methods + include Methods end end