hyped.core.features.mixins module¶
DType Mixins.
- class hyped.core.features.mixins.MethodRegistryMixin[source]¶
Bases:
objectA mixin class to provide method registration functionality.
- Fn = ~Fn¶
- execute_method(name: str, *args: Any, **kwargs: Any) Any[source]¶
Executes a registered method by its name with the provided arguments.
This method is a convenience function that combines the retrieval of a registered method using
get_method()and its subsequent execution. It ensures that the method is executed in the context of the current instance.- Parameters:
name (str) – The name of the method to execute.
*args (Any) – Positional arguments to pass to the method.
**kwargs (Any) – Keyword arguments to pass to the method.
- Returns:
The result of executing the registered method.
- Return type:
Any
- Raises:
NotImplementedError – If no method with the specified name is registered for the class of the current object.
- classmethod get_method(name: str) Callable[source]¶
Retrieve a registered method by name for the current class.
This class method accesses the
_methodsregistry using a key composed of the class’s qualified name and the method’s name. If the specified method is not found in the registry, it raises aNotImplementedError.- Parameters:
name (str) – The name of the method to retrieve.
- Returns:
The method registered under the specified name.
- Return type:
Callable
- Raises:
NotImplementedError – If no method with the given name is registered for the current class.
- classmethod register_method(name: str, force: bool = False) Callable[[Fn], Fn][source]¶
Registers a method for the class.
This decorator allows external sub-modules to register methods for the class, decoupling method implementations from the class definition itself.
- Parameters:
name (str) – The name of the method to register.
force (bool) – If
True, allows overriding an existing method. IfFalseand the method is already registered, raises aRuntimeError. Defaults toFalse.
- Returns:
A decorator function that registers the method and returns it unmodified.
- Return type:
- Raises:
RuntimeError – If a method with the same name is already registered and
forceis set toFalse.