Skip to content

Commit

Permalink
added Pagy.deprecate method
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 30, 2018
1 parent 645b57e commit 04ec860
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pagy/extras/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 04ec860

Please sign in to comment.