module Clickhouse::Rails::Config
Constants
- CLICKHOUSE_ROOT
- DEFAULT_CONFIG_PATH
Public Class Methods
config_mapper(source)
click to toggle source
# File lib/clickhouse/rails/config.rb, line 24 def self.config_mapper(source) return nil if source.nil? { urls: source['hosts']&.split(','), username: source['username'], password: source['password'] } end
init(config_path = nil)
click to toggle source
# File lib/clickhouse/rails/config.rb, line 11 def self.init(config_path = nil) config_path ||= DEFAULT_CONFIG_PATH exists = config_path && File.exist?(config_path) unless exists raise ConfigurationNotFound, "could not find the \"#{config_path}\" configuration file" end content = File.read(config_path) data = defined?(ERB) ? ERB.new(content).result : content source = YAML.safe_load(data)[defined?(::Rails) ? ::Rails.env : ENV['CLICKHOUSE_ENV']] config_mapper(source) end