graph LR
Chain["Chain"]
ChainWrapper["ChainWrapper"]
chain["chain"]
__getattr__["__getattr__"]
unwrap["unwrap"]
_wrap["_wrap"]
get_method["get_method"]
chain -- "instantiates" --> Chain
Chain -- "delegates method calls to" --> __getattr__
__getattr__ -- "retrieves functions via" --> get_method
__getattr__ -- "creates wrappers via" --> _wrap
_wrap -- "instantiates" --> ChainWrapper
Chain -- "manages operations in" --> ChainWrapper
ChainWrapper -- "executes operations through" --> unwrap
unwrap -- "processes" --> ChainWrapper
Chain -- "finalizes execution with" --> unwrap
The pydash chaining subsystem provides a fluent API for applying a sequence of utility functions to a value. The core of this subsystem revolves around the Chain class, which holds the current value and manages a queue of operations. The chain factory function serves as the entry point, initializing a new Chain instance. Operations are dynamically resolved via Chain.__getattr__, which retrieves the appropriate pydash function using get_method. These functions are then wrapped by _wrap into ChainWrapper instances. Each ChainWrapper encapsulates a pydash function and its arguments, allowing for lazy execution. The unwrap method, primarily within ChainWrapper, triggers the execution of these accumulated operations, ultimately yielding the final computed result.
The central component that orchestrates the sequential execution of chained methods. It holds the current value and manages the queue of operations.
Related Classes/Methods:
An adapter class that wraps individual pydash utility functions, making them compatible and callable within the Chain's execution context. It stores the method, arguments, and keyword arguments for a specific operation.
Related Classes/Methods:
The primary factory function that initializes and returns a new Chain instance, serving as the entry point for starting a fluent chain of operations.
Related Classes/Methods:
A dynamic method implemented on the Chain object that intercepts attribute access. It enables the fluent API by dynamically resolving method calls to pydash utility functions, retrieving them via get_method and wrapping them with _wrap.
Related Classes/Methods:
A method of ChainWrapper that triggers the sequential execution of all accumulated operations within the Chain and returns the final computed result. It recursively unwraps nested ChainWrapper instances.
Related Classes/Methods:
A helper method of the Chain class responsible for creating ChainWrapper instances. It ensures that pydash functions are correctly prepared and encapsulated for inclusion in the chain.
Related Classes/Methods:
A utility function that retrieves the actual pydash core function based on its name, which is then wrapped for chaining. It handles aliasing for methods ending with an underscore.
Related Classes/Methods: