diff --git a/lib/pagy/extras/shared.rb b/lib/pagy/extras/shared.rb index 005bf6167..7f9d4d450 100644 --- a/lib/pagy/extras/shared.rb +++ b/lib/pagy/extras/shared.rb @@ -27,4 +27,11 @@ def responsive end end + def self.deprecate(mod, old_meth, new_meth) + mod.send(:define_method, old_meth) do |pagy, id=caller(1,1)[0].hash| + Warning.warn "WARNING: The ##{old_meth} pagy helper method is deprecated and will be removed in 2.0; please use ##{new_meth} instead. More info at https://github.com/ddnexus/pagy/blob/master/DEPRECATIONS.md\n" + mod.instance_method(new_meth).arity == 1 ? send(new_meth, pagy) : send(new_meth, pagy, id) + end + end + end