Skip to content

Instantly share code, notes, and snippets.

@justinko
Created August 8, 2012 15:06
Show Gist options
  • Save justinko/3295724 to your computer and use it in GitHub Desktop.
Save justinko/3295724 to your computer and use it in GitHub Desktop.
Solr with Delegation
require 'delegate'
require 'singleton'
class Solr < DelegateClass(RSolr::Client)
include Singleton
def initialize
super RSolr.connect(url: url)
end
def delete_all!
delete_by_query '*:*'
commit
end
private
def url
"http://#{host}:#{port}#{path}"
end
def host
SOLR_CONFIG.fetch('host', 'localhost')
end
def port
SOLR_CONFIG.fetch('port', 8983)
end
def path
SOLR_CONFIG.fetch('path', '/solr')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment