Sha256: 05693abd30ffb7237e06e914fb2753dee8d63f672a06baea5244ecd4e238102c

Contents?: true

Size: 874 Bytes

Versions: 10

Compression:

Stored size: 874 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?
          RUBY_VERSION >= '1.9.3' && 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

10 entries across 10 versions & 1 rubygems

Version Path
ddtrace-0.26.1 lib/ddtrace/contrib/patchable.rb
ddtrace-0.26.0 lib/ddtrace/contrib/patchable.rb
ddtrace-0.25.1 lib/ddtrace/contrib/patchable.rb
ddtrace-0.25.0 lib/ddtrace/contrib/patchable.rb
ddtrace-0.24.0 lib/ddtrace/contrib/patchable.rb
ddtrace-0.23.3 lib/ddtrace/contrib/patchable.rb
ddtrace-0.23.2 lib/ddtrace/contrib/patchable.rb
ddtrace-0.23.1 lib/ddtrace/contrib/patchable.rb
ddtrace-0.23.0 lib/ddtrace/contrib/patchable.rb
ddtrace-0.22.0 lib/ddtrace/contrib/patchable.rb