class Esse::Config
Provides all configurations
Example
Esse.config do |conf| conf.indices_directory = 'app/indices' end
Constants
- ATTRIBUTES
- DEFAULT_CLUSTER_ID
Attributes
indices_directory[R]
The location of the indices. Defaults to the `app/indices`
Public Class Methods
new()
click to toggle source
# File lib/esse/config.rb, line 19 def initialize self.indices_directory = 'app/indices' @clusters = {} clusters(DEFAULT_CLUSTER_ID) # initialize the :default client end
Public Instance Methods
cluster_ids()
click to toggle source
# File lib/esse/config.rb, line 25 def cluster_ids @clusters.keys end
clusters(key = DEFAULT_CLUSTER_ID, **options) { |c| ... }
click to toggle source
# File lib/esse/config.rb, line 29 def clusters(key = DEFAULT_CLUSTER_ID, **options) return unless key id = key.to_sym (@clusters[id] ||= Cluster.new(id: id)).tap do |c| c.assign(options) if options yield c if block_given? end end
indices_directory=(value)
click to toggle source
# File lib/esse/config.rb, line 39 def indices_directory=(value) @indices_directory = value.is_a?(Pathname) ? value : Pathname.new(value) end
load(arg)
click to toggle source
# File lib/esse/config.rb, line 43 def load(arg) case arg when Hash assign(arg) when File, Pathname # @TODO Load JSON or YAML when String # @TODO Load JSON or YAML if File.exist?(arg) else raise ArgumentError, printf('could not load configuration using: %p', val) end end
Private Instance Methods
assign(hash)
click to toggle source
# File lib/esse/config.rb, line 58 def assign(hash) hash.each do |key, value| method = (ATTRIBUTES & [key.to_s, key.to_sym]).first next unless method public_send("#{method}=", value) end if (connections = hash['clusters'] || hash[:clusters]).is_a?(Hash) connections.each do |key, value| clusters(key).assign(value) if value.is_a?(Hash) end end true end