Sha256: 32f6a749d5d8041ba47973c7db2c076bca7cb5913f39483f63e4de15e8cbe1ad

Contents?: true

Size: 926 Bytes

Versions: 5

Compression:

Stored size: 926 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

5 entries across 5 versions & 1 rubygems

Version Path
fhir_stu3_models-3.1.1 lib/fhir_stu3_models/deprecate.rb
fhir_stu3_models-3.1.0 lib/fhir_stu3_models/deprecate.rb
fhir_stu3_models-3.0.2 lib/fhir_stu3_models/deprecate.rb
fhir_stu3_models-3.0.1 lib/fhir_stu3_models/deprecate.rb
fhir_stu3_models-3.0.0 lib/fhir_stu3_models/deprecate.rb