![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Install the gem and add to the application's Gemfile by executing:
$ bundle add simple_injector
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install simple_injector
First, declare your contract to your class
class CreateUserContract < SimpleInjector::Contract
register :api_client, -> { ApiClient.new }
end
The register
method receive a key, as a identifier of that instance and a proc that returns the object to be injectable into class
class CreateUser
include SimpleInjector
contract CreateUserContract
attr_injector :api_client
def initialize(user_params)
@user_params = user_params
end
def create
api_client.post @user_params
end
end
In your service class, include the SimpleInjector
module. This will be add the contract
and attr_injector
methods
The contract
method receives a class, your contract defined previously
The attr_injector
receives the key, has to be the same key defined in the contract and add a method in service class to retrieve the instance.
If you define more than one instance on contract class, you could add an attr_injector
for each instance. Ex:
class CreateUserContract < SimpleInjector::Contract
register :api_client, -> { ApiClient.new }
register :notify_user, -> { NotifyUser.new }
register :user_model, -> { User }
end
class CreateUser
include SimpleInjector
contract CreateUserContract
attr_injector :api_client
attr_injector :notify_user
attr_injector :user_model
def initialize(user_params)
@user_params = user_params
end
def create
user = user_model.save @user_params
api_client.post '/users/create/token', { id: user.id }
notify_user.notify(user)
end
end
The code is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that simple_injector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.