Sha256: be0747d636afa8b09084905b25977e50ce3ffbe64450ab7c173a88ecb03c2dfa

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require 'veritrans/version'
require 'veritrans/core_extensions'
require 'veritrans/config'
require 'veritrans/client'
require 'veritrans/api'
require 'veritrans/result'

if defined?(::Rails)
  require 'veritrans/events'
end

module Veritrans
  extend Veritrans::Client
  extend Veritrans::Api

  class << self
    def config(&block)
      if block
        instance_eval(&block)
      else
        Veritrans::Config
      end
    end

    alias_method :setup, :config

    # General logger
    # for rails apps it's === Rails.logger
    # for non-rails apps it's logging to stdout
    def logger
      return @logger if @logger
      if defined?(Rails)
        Rails.logger
      else
        unless @log
          require 'logger'
          @log = Logger.new(STDOUT)
          @log.level = Logger::INFO
        end
        @log
      end
    end

    def logger=(value)
      @logger = value
    end

    # Logger to file, only important information
    # For rails apps it will write log to RAILS_ROOT/log/veritrans.log
    def file_logger
      if !@file_logger
        if defined?(Rails) && Rails.root
          @file_logger = Logger.new(Rails.root.join("log/veritrans.log").to_s)
        else
          @file_logger = Logger.new("/dev/null")
        end
      end

      @file_logger
    end

    def file_logger=(value)
      @file_logger = value
    end

    def events
      Veritrans::Events if defined?(Veritrans::Events)
    end

    def decode_notification_json(input)
      return Veritrans::Client._json_decode(input)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritrans-2.0.4 lib/veritrans.rb
veritrans-2.0.3 lib/veritrans.rb
veritrans-2.0.2 lib/veritrans.rb