{"id":28509122,"url":"https://github.com/atomicobject/injection","last_synced_at":"2025-07-02T23:31:59.057Z","repository":{"id":1258887,"uuid":"1197706","full_name":"atomicobject/injection","owner":"atomicobject","description":"Injection is a simple dependency injection plugin for Rails. It allows you to inject objects into your controllers and observers which have been described in a yaml file (config/objects.yml).","archived":false,"fork":false,"pushed_at":"2013-09-13T01:21:58.000Z","size":556,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-06-08T22:08:04.696Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/atomicobject.png","metadata":{"files":{"readme":"README.rdoc","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":"2010-12-25T21:33:53.000Z","updated_at":"2020-08-18T17:59:50.000Z","dependencies_parsed_at":"2022-08-16T12:45:32.958Z","dependency_job_id":null,"html_url":"https://github.com/atomicobject/injection","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/atomicobject/injection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Finjection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Finjection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Finjection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Finjection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicobject","download_url":"https://codeload.github.com/atomicobject/injection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Finjection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263232725,"owners_count":23434727,"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","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":[],"created_at":"2025-06-08T22:07:29.134Z","updated_at":"2025-07-02T23:31:59.007Z","avatar_url":"https://github.com/atomicobject.png","language":"Ruby","readme":"== Description\n\nInjection is a simple dependency injection plugin for Rails 3. It allows you to inject objects into your controllers and observers which have been described in a yaml file (config/objects.yml).\n\n* http://github.com/atomicobject/injection\n\n(for the Rails 2 plugin install from the rails_2_plugin tag of this repository)\n\n== Features\n  \n* Declarative dependency injection that automatically instantiates ivars via the objects.yml file\n\n== Synopsis\n To specify objects to be injected from the DIY context into your controller or observer\n use the inject class method:\n\n   inject :one_component, :another\n\n=== Example\n\n This example defines a context with two objects, _foo_ and _bar_, which \n are injected into every instance of the WidgetController or WidgetObserver.  The objects \n are available as instance variables within the controller and observer.\n \n config/objects.yml:\n   ---\n   foo:\n   bar:\n \n lib/foo.rb:\n   class Foo\n     ...\n   end\n \n lib/bar.rb:\n   class Bar\n     ...\n   end\n \n app/controllers/widget_controller.rb:\n   class WidgetController \u003c ApplicationController\n     inject :foo, :bar\n \n     def index\n       render :text =\u003e \"{@foo.inspect} {@bar.inspect}\"\n     end\n   end\n  \n app/models/widget_observer.rb:\n   class WidgetObserver \u003c ActiveRecord::Observer\n     inject :foo, :bar\n     \n     before :save do |widget|\n      @foo.bar(widget)\n      @bar.foo(widget)\n     end\n   end \n \n=== Declarative Observations\n \n Observations on an Active Record object can be specified in a declarative way using\n the before and after class methods. The methods are invoked with a\n symbol which specifies what kind of event the observer is interested in, and a block \n that defines what actions it will perform.\n \n   class WidgetObserver \u003c ActiveRecord::Observer\n     before :update do |record|\n       ...\n     end\n \n     after :create do |record|\n       ...\n     end\n \n     after :validation do |record|\n       ...\n     end\n \n     before :validation do |record|\n       ...\n     end\n   end\n \n== Requirements\n\n* constructor[http://rubygems.org/gems/constructor]\n* diy[http://rubygems.org/gems/diy]\n\n== Install\n\n* gem install injection\n\n== License\n\n(The MIT License)\n\nCopyright (c) 2007-2011 Atomic Object\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicobject%2Finjection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicobject%2Finjection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicobject%2Finjection/lists"}