{"id":16957902,"url":"https://github.com/joshnuss/dependency","last_synced_at":"2025-10-26T21:33:36.825Z","repository":{"id":57489206,"uuid":"149209351","full_name":"joshnuss/dependency","owner":"joshnuss","description":"Dependency injection for Elixir","archived":false,"fork":false,"pushed_at":"2018-09-18T13:34:30.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-16T08:23:36.591Z","etag":null,"topics":["dependency-injection","elixir"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshnuss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-18T01:14:50.000Z","updated_at":"2018-09-18T13:34:33.000Z","dependencies_parsed_at":"2022-08-29T09:10:15.563Z","dependency_job_id":null,"html_url":"https://github.com/joshnuss/dependency","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joshnuss/dependency","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fdependency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fdependency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fdependency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fdependency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshnuss","download_url":"https://codeload.github.com/joshnuss/dependency/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshnuss%2Fdependency/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280995980,"owners_count":26426667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","elixir"],"created_at":"2024-10-13T22:20:27.525Z","updated_at":"2025-10-26T21:33:36.799Z","avatar_url":"https://github.com/joshnuss.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dependency\n\nDependency injection for Elixir. [Full documentation](https://hexdocs.pm/dependency)\n\nDependency injection allows you to swap out dependencies when unit testing your modules.\n\nIn test mode, dependency resolution is dynamic (it uses a `Registry` lookup the current implementation).\nIn dev and production mode, doing a lookup would be slow and cause a bottleneck, so the dependency is compiled inline with a macro - eliminating any perormance hit.\n\nInspired by [constantizer](https://github.com/aaronrenner/constantizer)\n\n## Installation\n\nThe package can be installed by adding `dependency` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:dependency, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\nAlso, you'll need to add the application to your list of applications\n\n```elixir\ndef application do\n  [\n    # ...\n    extra_applications: [:dependency],\n  ]\nend\n```\n\n## Usage\n\n### Resolving a dependency\n\n```elixir\nimport Dependency\n\nmod = Dependency.resolve(MyModule)\n```\n\n### Registering an implementation\n\n```elixir\nDependency.register(MyModule, MyImplementation)\n```\n\n### Defining a constant\n\n```elixir\ndefmodule Example do\n  import Dependency\n\n  # define a public constant/accesor\n  defconst :foo, Foo\nend\n\n# call accesor to resolve dependecy\nExample.foo == Foo\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshnuss%2Fdependency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshnuss%2Fdependency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshnuss%2Fdependency/lists"}