module FHIR::DSTU2::Deprecate

add support for deprecating instance and class methods

Public Instance Methods

deprecate(old_method, new_method) click to toggle source
# File lib/fhir_dstu2_models/deprecate.rb, line 5
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::DSTU2.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::DSTU2.logger.warn message
      send(new_method, *args, &block)
    end
  end
end