lib/waistband/configuration.rb in waistband-0.2.5 vs lib/waistband/configuration.rb in waistband-0.3.0

- old
+ new

@@ -1,8 +1,9 @@ require 'yaml' require 'singleton' require 'active_support/core_ext/hash/indifferent_access' +require 'digest/sha1' module Waistband class Configuration include Singleton @@ -24,27 +25,27 @@ def index(name) @indexes[name] ||= YAML.load_file("#{config_dir}/waistband_#{name}.yml")[@env].with_indifferent_access end - def hostname - "#{host}:#{port}" - end - def method_missing(method_name, *args, &block) return current_server[method_name] if current_server[method_name] return @yml_config[method_name] if @yml_config[method_name] super end + def servers + @servers ||= @yml_config['servers'].map do |server_name, config| + config.merge({ + '_id' => Digest::SHA1.hexdigest("#{config['host']}:#{config['port']}") + }) + end + end + private def current_server servers.sample - end - - def servers - @servers ||= @yml_config['servers'].map {|server_name, config| config} end # /private end