class ElasticsearchEnvConfig
Constants
- VERSION
Public Class Methods
new(env: ENV)
click to toggle source
# File lib/elasticsearch_env_config.rb, line 6 def initialize(env: ENV) @env = env end
Public Instance Methods
to_h()
click to toggle source
# File lib/elasticsearch_env_config.rb, line 10 def to_h {}.tap do |config| if @env.include?("ELASTICSEARCH_HOSTS") config[:hosts] = @env.fetch("ELASTICSEARCH_HOSTS").split(/[,\s]+/) config[:index] = @env.fetch("ELASTICSEARCH_INDEX") { raise Error, "missing environment variable ELASTICSEARCH_INDEX" } %i[ user password date_pattern host application ].each do |key| v = @env["ELASTICSEARCH_#{key.upcase}"] config[key] = v if v end end end end