Created
August 8, 2012 15:06
-
-
Save justinko/3295724 to your computer and use it in GitHub Desktop.
Solr with Delegation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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