Sha256: 9cbb918b8d9ec831552a50386d8153e9c3407dc1467154d7244253e13b511464

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

require 'logger'

module Killbill::Litle
  mattr_reader :logger
  mattr_reader :config
  mattr_reader :gateways
  mattr_reader :kb_apis
  mattr_reader :initialized
  mattr_reader :test

  def self.initialize!(logger=Logger.new(STDOUT), conf_dir=File.expand_path('../../../', File.dirname(__FILE__)), kb_apis = nil)
    @@logger = logger
    @@kb_apis = kb_apis

    config_file = "#{conf_dir}/litle.yml"
    @@config = Properties.new(config_file)
    @@config.parse!
    @@test = @@config[:litle][:test]

    @@gateways = Killbill::Litle::Gateway.from_config(@@config[:litle])

    if defined?(JRUBY_VERSION)
      # See https://github.com/jruby/activerecord-jdbc-adapter/issues/302
      require 'jdbc/mysql'
      Jdbc::MySQL.load_driver(:require) if Jdbc::MySQL.respond_to?(:load_driver)
    end

    ActiveRecord::Base.establish_connection(@@config[:database])

    @@initialized = true
  end

  def self.gateway_for_currency(currency)
    currency_sym = currency.to_s.upcase.to_sym
    gateway = @@gateways[currency_sym]
    raise "Gateway for #{currency} not configured!" if gateway.nil?
    gateway
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
killbill-litle-1.8.2 lib/litle/config/configuration.rb
killbill-litle-1.8.1 lib/litle/config/configuration.rb
killbill-litle-1.8.0 lib/litle/config/configuration.rb
killbill-litle-1.7.1 lib/litle/config/configuration.rb
killbill-litle-1.7.0 lib/litle/config/configuration.rb
killbill-litle-1.6.0 lib/litle/config/configuration.rb
killbill-litle-1.5.1 lib/litle/config/configuration.rb
killbill-litle-1.5.0 lib/litle/config/configuration.rb
killbill-litle-1.4.0 lib/litle/config/configuration.rb
killbill-litle-1.3.0 lib/litle/config/configuration.rb