Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
In a Rails application, it is often required to fill a gap between Models and Views. There are of course, many differents ways to fill this gap, one of these is decorators and its variants exhibits or presenters.
The main difference between decorators, exhibits and presenters are their proximity with the rendering layer. Typically a decorator is not meant to be contextualized, whereas an exhibit is intended to have access to rendering context.
This gem provide an easy way to create theese concepts in Ruby.
Add this line to your application's Gemfile:
gem 'exposant'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install exposant
Exposant objects are intended to overload class (scopes) and instance methods of any other object. The default type is exposant, choosing between decorator, exhibit or any other type name is up to you. There is no magic involved for the context, you just have to call contextualize and provide the required context.
Consider having a User model with first_name
and last_name
# app/models/user.rb
class User < ActiveRecord::Base
include Exposant::Model
has_exposant type: :decorator
end
# app/decorators/user_decorator.rb
class UserDecorator < Exposant::Base
exposant_type :decorator
def full_name
"#{first_name} #{last_name}"
end
end
Then you may want to use your brand new decorator in your controller
# app/controllers/users_controller.rb
class UsersController < DefaultController
def index
@users = User.decorator(User.all)
end
def show
@user = User.find(...).decorator
end
end
If you want to contextualize a presenter, for example in a Rails application.
# app/controllers/users_controller.rb
class UsersController < DefaultController
def index
@users = User.presenter(User.all)
@users.contextualize(self)
end
def show
@user = User.find(...).presenter
@user.contextualize(self)
end
end
After checking out the repo, run bin/setup
to install dependencies. You can
also run bin/console
for an interactive prompt that will allow you to
experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/kmmndr/exposant.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that exposant 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.