# Library for creating Dependency Injection Pattern
## Usage
``` python
from nttinjector import dependency_inject, Injector
class Model:
count = 0
def __init__(self, strName: str = "") -> None:
self._strName = strName
self.CreateNewModel()
def __repr__(self) -> str:
return f"<Model name=\"{self._strName}\" />"
@classmethod
def CreateNewModel(cls):
cls.count += 1
@classmethod
def GetModelInstances(cls):
return cls.count
@dependency_inject(Model)
class ViewModel:
count = 0
def __init__(self, mModel: Model, strName: str = "") -> None:
self._mModel = mModel
self._strName = strName
self.CreateNewModel()
@classmethod
def CreateNewModel(cls):
cls.count += 1
@classmethod
def GetModelInstances(cls):
return cls.count
def __repr__(self) -> str:
return f"<ViewModel name=\"{self._strName}\" />"
@dependency_inject(ViewModel, Model)
class View:
def __init__(self, viewModel: ViewModel, mModel: Model, strName: str = "") -> None:
self._viewModel = viewModel
self._model = mModel
self._strName = strName
def __repr__(self) -> str:
return f"<View name=\"{self._strName}\" />"
```
Then use the View as normal
``` python
view = View()
print(view._model)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/threezinedine/ntt-injector",
"name": "ntt-injector",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "dependency injector",
"author": "threezinedine",
"author_email": "threezinedine@email.com",
"download_url": "https://files.pythonhosted.org/packages/fa/69/e84ad4af2d5a5b41da032a2d2b5b966521ead774cc2b7aabd5cef98711d8/ntt-injector-1.1.0.tar.gz",
"platform": null,
"description": "# Library for creating Dependency Injection Pattern\r\n\r\n## Usage\r\n\r\n``` python\r\nfrom nttinjector import dependency_inject, Injector\r\n\r\nclass Model:\r\n count = 0\r\n\r\n def __init__(self, strName: str = \"\") -> None:\r\n self._strName = strName\r\n self.CreateNewModel()\r\n\r\n def __repr__(self) -> str:\r\n return f\"<Model name=\\\"{self._strName}\\\" />\"\r\n\r\n @classmethod\r\n def CreateNewModel(cls):\r\n cls.count += 1\r\n\r\n @classmethod\r\n def GetModelInstances(cls):\r\n return cls.count\r\n\r\n\r\n@dependency_inject(Model)\r\nclass ViewModel:\r\n count = 0\r\n\r\n def __init__(self, mModel: Model, strName: str = \"\") -> None:\r\n self._mModel = mModel\r\n self._strName = strName\r\n self.CreateNewModel()\r\n\r\n @classmethod\r\n def CreateNewModel(cls):\r\n cls.count += 1\r\n\r\n @classmethod\r\n def GetModelInstances(cls):\r\n return cls.count\r\n\r\n def __repr__(self) -> str:\r\n return f\"<ViewModel name=\\\"{self._strName}\\\" />\"\r\n\r\n\r\n@dependency_inject(ViewModel, Model)\r\nclass View:\r\n def __init__(self, viewModel: ViewModel, mModel: Model, strName: str = \"\") -> None:\r\n self._viewModel = viewModel\r\n self._model = mModel\r\n self._strName = strName\r\n\r\n def __repr__(self) -> str:\r\n return f\"<View name=\\\"{self._strName}\\\" />\"\r\n```\r\n\r\nThen use the View as normal\r\n\r\n``` python\r\nview = View()\r\n\r\nprint(view._model)\r\n```\r\n\r\n",
"bugtrack_url": null,
"license": "",
"summary": "The small library for configuring the depedency injector design pattern",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/threezinedine/ntt-injector",
"Source": "https://github.com/threezinedine/ntt-injector",
"Tracker": "https://github.com/threezinedine/ntt-injector/issues"
},
"split_keywords": [
"dependency",
"injector"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f485f9d6fb98429d4aece9641be11bc7fbad92a986a06e3960e48d7a49992fec",
"md5": "4208a691d7b6941617b24329315bd6e3",
"sha256": "0fb757968869e6009a1ddce0bad74d8be551d7639cccb59d4f8649f1ede81e38"
},
"downloads": -1,
"filename": "ntt_injector-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4208a691d7b6941617b24329315bd6e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3557,
"upload_time": "2023-12-01T05:10:26",
"upload_time_iso_8601": "2023-12-01T05:10:26.868921Z",
"url": "https://files.pythonhosted.org/packages/f4/85/f9d6fb98429d4aece9641be11bc7fbad92a986a06e3960e48d7a49992fec/ntt_injector-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fa69e84ad4af2d5a5b41da032a2d2b5b966521ead774cc2b7aabd5cef98711d8",
"md5": "cf44374eb8a1eae0f3decce34ab2fbc3",
"sha256": "e58653fd832f47ce50e4ab6b1bc472b2e6871cb61629025d4dda81efe2f9c52f"
},
"downloads": -1,
"filename": "ntt-injector-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "cf44374eb8a1eae0f3decce34ab2fbc3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2555,
"upload_time": "2023-12-01T05:10:28",
"upload_time_iso_8601": "2023-12-01T05:10:28.316640Z",
"url": "https://files.pythonhosted.org/packages/fa/69/e84ad4af2d5a5b41da032a2d2b5b966521ead774cc2b7aabd5cef98711d8/ntt-injector-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-01 05:10:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "threezinedine",
"github_project": "ntt-injector",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "ntt-injector"
}