[IMP] models: turn _patch_method() and _revert_method() into class methods

This makes the patching mechanism more flexible, and enables patching BaseModel,
for instance. This should fix #1501.