module ActiveSupport::Deprecation::MethodWrapper

def deprecate_methods(target_module, *method_names)

# => "DEPRECATION WARNING: baz is deprecated and will be removed from Rails 4.1 (use Bar#baz instead)."
Fred.baz

# => "DEPRECATION WARNING: bar is deprecated and will be removed from Rails 4.1 (use qux instead)."
Fred.bar

# => "DEPRECATION WARNING: foo is deprecated and will be removed from Rails 4.1."
Fred.foo

# => [:foo, :bar, :baz]
ActiveSupport::Deprecation.deprecate_methods(Fred, :foo, bar: :qux, baz: 'use Bar#baz instead')

end
def baz; end
def bar; end
def foo; end

extend self
module Fred

Declare that a method has been deprecated.
def deprecate_methods(target_module, *method_names)
  options = method_names.extract_options!
  deprecator = options.delete(:deprecator) || ActiveSupport::Deprecation.instance
  method_names += options.keys
  method_names.each do |method_name|
    target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
      target_module.send(:define_method, "#{target}_with_deprecation#{punctuation}") do |*args, &block|
        deprecator.deprecation_warning(method_name, options[method_name])
        send(:"#{target}_without_deprecation#{punctuation}", *args, &block)
      end
    end
  end
end