{"id":18785650,"url":"https://github.com/dbackowski/trivial_decorator","last_synced_at":"2026-04-26T16:32:40.324Z","repository":{"id":59158094,"uuid":"112654038","full_name":"dbackowski/trivial_decorator","owner":"dbackowski","description":"A simple decorator for Rails","archived":false,"fork":false,"pushed_at":"2018-11-04T10:10:46.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-20T01:58:47.262Z","etag":null,"topics":["decorator","decorator-pattern","decorators","gem","rails","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbackowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-30T19:56:03.000Z","updated_at":"2018-11-04T10:10:48.000Z","dependencies_parsed_at":"2022-09-13T20:11:18.335Z","dependency_job_id":null,"html_url":"https://github.com/dbackowski/trivial_decorator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dbackowski/trivial_decorator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Ftrivial_decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Ftrivial_decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Ftrivial_decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Ftrivial_decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbackowski","download_url":"https://codeload.github.com/dbackowski/trivial_decorator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Ftrivial_decorator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32305035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorator","decorator-pattern","decorators","gem","rails","ruby"],"created_at":"2024-11-07T20:49:14.994Z","updated_at":"2026-04-26T16:32:40.308Z","avatar_url":"https://github.com/dbackowski.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrivialDecorator [![Build Status](https://travis-ci.org/dbackowski/trivial_decorator.svg?branch=master)](https://travis-ci.org/dbackowski/trivial_decorator)\n\nA simple decorator for Rails.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'trivial_decorator'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install trivial_decorator\n\n## Usage\n\n#### Writing Decorators\n\nDecorators inherit from TrivialDecorator::Base, live in your app/decorators directory, and are named for the model that they decorate:\n\n```ruby\n# app/decorators/user_decorator.rb\n\nclass UserDecorator \u003c TrivialDecorator::Base\n  def full_name\n    first_name + \" \" + last_name\n  end\nend\n```\n\n#### Accessing helpers\n\n```ruby\n# app/decorators/user_decorator.rb\n\nclass UserDecorator \u003c TrivialDecorator::Base\n  def full_name\n    h.content_tag(:strong, first_name + \" \" + last_name)\n  end\nend\n```\n\n#### Decorating Objects\n\n```ruby\n# app/controllers/users_controller.rb\n\nclass UsersController \u003c ApplicationController\n  def index\n    @users = decorate(User.all)\n  end\nend\n```\n\nThis will use UserDecorator, if you want to use other decorator, just pass his class name as second param to decorate.\n\n```ruby\n# app/controllers/users_controller.rb\n\nclass UsersController \u003c ApplicationController\n  def index\n    @users = decorate(User.all, OtherDecorator)\n  end\nend\n```\n\n## Contributing\n\nBug 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](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the TrivialDecorator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dbackowski/trivial_decorator/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbackowski%2Ftrivial_decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbackowski%2Ftrivial_decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbackowski%2Ftrivial_decorator/lists"}