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.
LittleDecorator is an ultra-lightweight decorator for Rails models. There are only 42 lines of code in lib.
Include it in your Gemfile.
gem 'little_decorator'
Add your decorator in app/decorators
:
# app/decorators/user_decorator.rb
class UserDecorator < LittleDecorator
def full_name
"#{first_name} #{last_name}"
end
def updated_at
record.updated_at.strftime("%A, %B %e, %Y")
end
end
Method calls are sent to the model via method_missing
, so you can call model methods directly as in the full_name
method defined above.
Call model methods with record
when you want to override a method but still get to the original model.
You can access helper methods and route helpers in your decorators.
The API consists of a single method: decorate
. This method will be available in your controllers and views. You can call decorate
on an object or a collection. Examples:
Just call decorate
:
decorate(user)
Just call decorate
:
<%= decorate(user) %>
Just call decorate
. You'll get an array of decorated objects
decorate(users)
<%= decorate(users) %>
For use with Rails.vim. Place in config/projections.json
.
{
"app/decorators/*_decorator.rb": {
"command": "decorator",
"alternate": "spec/decorators/%s_decorator_spec.rb",
"template": "class %SDecorator < LittleDecorator\nend"
}
}
Pull requests are welcome, but I want to keep this gem simple.
FAQs
Unknown package
We found that little_decorator 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.