Sha256: 48f56d3cffad8e0ac977057192b567396eaa1c86ad934a150f18a2c893445056

Contents?: true

Size: 932 Bytes

Versions: 6

Compression:

Stored size: 932 Bytes

Contents

module Datadog
  module Contrib
    # Base provides features that are shared across all integrations
    module Patchable
      def self.included(base)
        base.send(:extend, ClassMethods)
        base.send(:include, InstanceMethods)
      end

      # Class methods for integrations
      module ClassMethods
        def version
          nil
        end

        def present?
          !version.nil?
        end

        def compatible?
          Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(VERSION::MINIMUM_RUBY_VERSION) && present?
        end
      end

      # Instance methods for integrations
      module InstanceMethods
        def patcher
          nil
        end

        def patch
          if !self.class.compatible? || patcher.nil?
            Datadog::Tracer.log.warn("Unable to patch #{self.class.name}")
            return
          end

          patcher.patch
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ls-trace-0.1.2 lib/ddtrace/contrib/patchable.rb
ddtrace-0.30.1 lib/ddtrace/contrib/patchable.rb
ddtrace-0.30.0 lib/ddtrace/contrib/patchable.rb
ddtrace-0.29.1 lib/ddtrace/contrib/patchable.rb
ls-trace-0.1.1 lib/ddtrace/contrib/patchable.rb
ddtrace-0.29.0 lib/ddtrace/contrib/patchable.rb