Class: Killbill::Chartmogul::UpdaterInitializer

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/chart_mogul/updater_initializer.rb

Instance Method Summary collapse

Instance Method Details

#initialize!(config_key_name, config_file, kb_apis, logger) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chart_mogul/updater_initializer.rb', line 10

def initialize!(config_key_name, config_file, kb_apis, logger)
  @config_key_name = config_key_name
  @kb_apis = kb_apis
  @logger = logger

  @per_tenant_config_cache = ThreadSafe::Cache.new

  # Look for global config
  if !config_file.blank? && Pathname.new(config_file).file?
    path = Pathname.new(config_file).expand_path
    @glob_config = YAML.load(ERB.new(File.read(path.to_s)).result)
  else
    @glob_config = {}
  end
end

#recycle_updater(kb_tenant_id) ⇒ Object



26
27
28
# File 'lib/chart_mogul/updater_initializer.rb', line 26

def recycle_updater(kb_tenant_id)
  @per_tenant_config_cache[kb_tenant_id] = nil
end

#updater(kb_tenant_id) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/chart_mogul/updater_initializer.rb', line 30

def updater(kb_tenant_id)
  config = get_tenant_config(kb_tenant_id)
  if config.nil?
    @logger.warn "ChartMogul wasn't configured properly for kbTenantId='#{kb_tenant_id}'"
    return nil
  else
    ::Killbill::Chartmogul::Updater.new(config[:chartmogul], @kb_apis, @logger)
  end
end