Module: TBK::Webpay

Defined in:
lib/tbk/errors.rb,
lib/tbk/webpay/logger.rb,
lib/tbk/webpay/payment.rb,
lib/tbk/webpay/encryption.rb,
lib/tbk/webpay/confirmation.rb,
lib/tbk/webpay/logger/base_logger.rb,
lib/tbk/webpay/logger/null_logger.rb,
lib/tbk/webpay/logger/official_logger.rb

Defined Under Namespace

Modules: Config, Encryption, Logger Classes: Confirmation, EncryptionError, Payment, PaymentError

Class Method Summary collapse

Class Method Details

.logger(logger = nil, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tbk/webpay/logger.rb', line 15

def self.logger(logger=nil, &block)
  if logger
    klass = case logger
            when Symbol
              self.logger_for_symbol(logger)
            when Class
              logger
            else
              raise ArgumentError, "first argument must be a Symbol or a Class"
            end

    @logger = klass.new(&block)
  end

  @logger
end

.logger_for_symbol(sym) ⇒ Object

Get the logger class for a given Symbol



6
7
8
9
10
11
12
13
# File 'lib/tbk/webpay/logger.rb', line 6

def self.logger_for_symbol(sym)
  logger_class_name = "#{sym.to_s.gsub(/(^\w)|(_\w)/){ |s| s.upcase[-1] }}Logger"
  logger_require_path = "tbk/webpay/logger/#{sym}_logger"

  require logger_require_path

  TBK::Webpay::Logger.const_get(logger_class_name)
end