Sha256: 810ea4ecf9d75389a72f4d8e0eb288f0d72ac0a48b2daca3788703db234b3913

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

module Mblox
  class << self
    def config
      @config ||= Configuration.new
    end
  end

  def self.configure
    yield self.config
  end

  class Configuration
    attr_accessor :outbound_url, :profile_id, :sender_id, :password, :partner_name, :tariff, :service_id
    attr_reader :logger, :log_level
    def initialize
      @logger = Rails.logger if defined?(::Rails)
      @log_level = :debug
    end

    def log_at level
      validate @logger, level
      @log_level = level
    end
    def logger= logger
      validate logger, @log_level
      @logger = logger
    end
    private
      def validate logger, level
	raise ArgumentError, "Mblox log level must be set to :fatal, :error, :warn, :info or :debug" if (logger && !logger.respond_to?(level))
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mblox-0.0.1 lib/mblox/configuration.rb