Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
parameter_transformers
Advanced tools
This gem provides a proxy which can encapsulate transformers to be applied to given method/parameter combinations before the target method is called.
It is useful for scenarios where you might have a stateful value that needs to be consistently applied to other parameters being passed to library code.
Add this line to your application's Gemfile:
gem 'parameter_transformers'
And then execute:
$ bundle
Or install it yourself as:
$ gem install parameter_transformers
Here's an example of using the proxy to consistently apply an authentication header to all requests made with the RestClient gem:
require 'rest_client'
require 'parameter_transformers'
add_auth_header = ->(headers) { (headers || {}).merge('AUTH-HEADER' => 'key') }
transformers = [:get, :post, :put, :delete].map do |method|
[[method, :headers], add_auth_header]
end
rc = ParameterTransformers::Proxy.new(RestClient, Hash[transformers])
# automatically adds {'AUTH-HEADER' => 'key'} to headers on all calls now
rc.get('http://somesite.com')
rc.post('http://somesite.com', {foo: 'bar'})
rc.put('http://somesite.com', {foo: 'bar'})
rc.delete('http://somesite.com')
Note per example above the format for transformers is a hash where keys are an array of [:method_name, :argument_name] and values are procs which receive a copy of the passed argument, and return the transformed value to be passed to the method on the target object
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that parameter_transformers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.