Sha256: 15d5e3516dc01286898c97d81a7a4ab4780ca9eb43489f340863dbdaf344266b

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

module FHIR
  module STU3
    # add support for deprecating instance and class methods
    module Deprecate
      def deprecate(old_method, new_method)
        if instance_methods.include? new_method
          define_method(old_method) do |*args, &block|
            message = "DEPRECATED: `#{old_method}` has been deprecated. Use `#{new_method}` instead. Called from #{caller.first}"
            FHIR::STU3.logger.warn message
            send(new_method, *args, &block)
          end
        end
        return unless methods.include? new_method

        (class << self; self; end).instance_eval do
          define_method(old_method) do |*args, &block|
            message = "DEPRECATED: `#{old_method}` has been deprecated. Use `#{new_method}` instead. Called from #{caller.first}"
            FHIR::STU3.logger.warn message
            send(new_method, *args, &block)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fhir_stu3_models-3.2.0 lib/fhir_stu3_models/deprecate.rb