
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
A simple decorator for Rails.
Add this line to your application's Gemfile:
gem 'trivial_decorator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install trivial_decorator
Decorators inherit from TrivialDecorator::Base, live in your app/decorators directory, and are named for the model that they decorate:
# app/decorators/user_decorator.rb
class UserDecorator < TrivialDecorator::Base
def full_name
first_name + " " + last_name
end
end
# app/decorators/user_decorator.rb
class UserDecorator < TrivialDecorator::Base
def full_name
h.content_tag(:strong, first_name + " " + last_name)
end
end
# app/controllers/users_controller.rb
class UsersController < ApplicationController
def index
@users = decorate(User.all)
end
end
This will use UserDecorator, if you want to use other decorator, just pass his class name as second param to decorate.
# app/controllers/users_controller.rb
class UsersController < ApplicationController
def index
@users = decorate(User.all, OtherDecorator)
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/dbackowski/trivial_decorator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the TrivialDecorator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that trivial_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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.