Skip to content

Commit

Permalink
Add .bind() method to re-enable bound-methods after deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
delivrance committed Oct 27, 2019
1 parent 9afd244 commit 1609efb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pyrogram/client/types/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ class Object(metaclass=Meta):
def __init__(self, client: "pyrogram.BaseClient" = None):
self._client = client

if self._client is None:
del self._client
def bind(self, client: "pyrogram.BaseClient"):
"""Bind a Client instance to this Pyrogram Object
Parameters:
client (:obj:`Client`):
The Client instance to bind this object with. Useful to re-enable bound methods after serializing and
deserializing Pyrogram objects with ``repr`` and ``eval``.
"""
self._client = client

@staticmethod
def default(obj: "Object"):
Expand Down

0 comments on commit 1609efb

Please sign in to comment.