Sha256: aa0052263ef47b99ac69d17264f261fbf9726a81f8da0d03e6e0b3795ac5431d
Contents?: true
Size: 1.83 KB
Versions: 6
Compression:
Stored size: 1.83 KB
Contents
module Sunspot #:nodoc: module Rails #:nodoc: # # Sunspot::Rails is configured via the config/sunspot.yml file, which # contains properties keyed by environment name. A sample sunspot.yml file # would look like: # # development: # solr: # hostname: localhost # port: 8982 # test: # solr: # hostname: localhost # port: 8983 # # Sunspot::Rails uses the configuration to set up the Solr connection, as # well as for starting Solr with the appropriate port using the # <code>rake sunspot:solr:start</code> task. # class Configuration # # The host name at which to connect to Solr. Default 'localhost'. # # ==== Returns # # String:: host name # def hostname @hostname ||= if user_configuration.has_key?('solr') user_configuration['solr']['hostname'] end || 'localhost' end # # The port at which to connect to Solr. Default 8983. # # ==== Returns # # Integer:: port # def port @port ||= if user_configuration.has_key?('solr') user_configuration['solr']['port'] end || 8983 end private # # Memoized hash of configuration options for the current Rails environment # as specified in config/sunspot.yml # # ==== Returns # # Hash:: configuration options for current environment # def user_configuration @user_configuration ||= begin path = File.join(::Rails.root, 'config', 'sunspot.yml') if File.exist?(path) File.open(path) do |file| YAML.load(file)[::Rails.env] end end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems