Sha256: 99014d292d7d458e3849d0f1dcda0be6c9d716a7f55edad547aa297a120561e3

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'active_support/core_ext/module/deprecation'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/array/extract_options'

module ActiveSupport
  class << Deprecation
    # Declare that a method has been deprecated.
    def deprecate_methods(target_module, *method_names)
      options = method_names.extract_options!
      method_names += options.keys

      method_names.each do |method_name|
        target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
          target_module.module_eval(<<-end_eval, __FILE__, __LINE__ + 1)
            def #{target}_with_deprecation#{punctuation}(*args, &block)          # def generate_secret_with_deprecation(*args, &block)
              ::ActiveSupport::Deprecation.warn(                                 #   ::ActiveSupport::Deprecation.warn(
                ::ActiveSupport::Deprecation.deprecated_method_warning(          #     ::ActiveSupport::Deprecation.deprecated_method_warning(
                  :#{method_name},                                               #       :generate_secret,
                  #{options[method_name].inspect}),                              #       "You should use ActiveSupport::SecureRandom.hex(64)"),
                caller                                                           #     caller
              )                                                                  #   )
              send(:#{target}_without_deprecation#{punctuation}, *args, &block)  #   send(:generate_secret_without_deprecation, *args, &block)
            end                                                                  # end
          end_eval
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activesupport-3.0.0.beta lib/active_support/deprecation/method_wrappers.rb