Module: ReadConfigFile

Extended by:
ActiveSupport::Concern
Included in:
Mints::Client, Mints::ContactAPIController, Mints::PublicAPIController, Mints::UserAPIController
Defined in:
lib/mints/controllers/concerns/read_config_file.rb

Instance Method Summary collapse

Instance Method Details

#set_config_variablesObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mints/controllers/concerns/read_config_file.rb', line 10

def set_config_variables
  if File.exists?("#{Rails.root}/mints_config.yml.erb")

    template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
    config = YAML.safe_load template.result(binding)
    @host = config["mints"]["host"]
    @api_key = config["mints"]["api_key"]
    @debug = !!config["sdk"]["debug"]
    @redis_config = config['redis_cache']
    @use_cache = config['redis_cache']['use_cache']

    if @use_cache
      @redis_server = Redis.new(
        host: config['redis_cache']['redis_host'],
        port: config['redis_cache']['redis_port'] || 6379,
        db: config['redis_cache']['redis_db'] || 1
      )
    end
  end
end