Sha256: 4ca1d62c3bbfccd0766e532f03e6bb62a4c47704882a749bd3f215f010d41655

Contents?: true

Size: 936 Bytes

Versions: 4

Compression:

Stored size: 936 Bytes

Contents

module Timber
  # Base class for `Timber::Integrations::*`.
  #
  # @private
  class Integrator
    class RequirementNotMetError < StandardError; end

    class << self
      attr_writer :enabled

      def enabled?
        @enabled != false
      end

      def integrate!(*args)
        if !enabled?
          Config.instance.debug_logger.debug("#{name} integration disabled, skipping") if Config.instance.debug_logger
          return false
        end

        new(*args).integrate!
        Config.instance.debug_logger.debug("Integrated #{name}") if Config.instance.debug_logger
        true
      # RequirementUnsatisfiedError is the only silent failure we support
      rescue RequirementNotMetError => e
        Config.instance.debug_logger.debug("Failed integrating #{name}: #{e.message}") if Config.instance.debug_logger
        false
      end
    end

    def integrate!
      raise NotImplementedError.new
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/integrator.rb
timber-2.0.23 lib/timber/integrator.rb
timber-2.0.22 lib/timber/integrator.rb
timber-2.0.21 lib/timber/integrator.rb