mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Update docs
This commit is contained in:
parent
54544f66a0
commit
2c87f1c28a
@ -65,6 +65,11 @@ class MongoDBConnection(Connection):
|
||||
|
||||
|
||||
def collection(name):
|
||||
"""Return a lazy object that can be used to compose a query.
|
||||
|
||||
Args:
|
||||
name (str): the name of the collection to query.
|
||||
"""
|
||||
return Lazy()[name]
|
||||
|
||||
|
||||
|
@ -160,8 +160,17 @@ def is_genesis_block(block):
|
||||
|
||||
|
||||
class Lazy:
|
||||
"""Lazy objects are useful to create chains of methods to
|
||||
execute later.
|
||||
|
||||
A lazy object records the methods that has been called, and
|
||||
replay them when the :py:meth:`run` method is called. Note that
|
||||
:py:meth:`run` needs an object `instance` to replay all the
|
||||
methods that have been recorded.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Instantiate a new Lazy object."""
|
||||
self.stack = []
|
||||
|
||||
def __getattr__(self, name):
|
||||
@ -178,6 +187,12 @@ class Lazy:
|
||||
return self
|
||||
|
||||
def run(self, instance):
|
||||
"""Run the recorded chain of methods on `instance`.
|
||||
|
||||
Args:
|
||||
instance: an object.
|
||||
"""
|
||||
|
||||
last = instance
|
||||
|
||||
for item in self.stack:
|
||||
|
Loading…
x
Reference in New Issue
Block a user