{"id":22025172,"url":"https://github.com/drexed/lite-decorator","last_synced_at":"2026-01-30T22:05:40.067Z","repository":{"id":35093743,"uuid":"205741275","full_name":"drexed/lite-decorator","owner":"drexed","description":"Ruby Decorator based framework (aka decorator/presenter objects)","archived":false,"fork":false,"pushed_at":"2024-12-02T22:58:41.000Z","size":73,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T11:43:23.076Z","etag":null,"topics":["decorator","presenter","ruby"],"latest_commit_sha":null,"homepage":"https://drexed.github.io/lite-decorator","language":"Ruby","has_issues":false,"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/drexed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-01T22:51:48.000Z","updated_at":"2024-10-09T03:26:22.000Z","dependencies_parsed_at":"2024-11-30T07:14:55.606Z","dependency_job_id":"3d46de9a-a8c0-4675-9b4c-05a7fd6fa178","html_url":"https://github.com/drexed/lite-decorator","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.050000000000000044","last_synced_commit":"fe5a099eda06f13dfe6a108a789a5153de2cc14e"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/lite-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252851558,"owners_count":21814171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","presenter","ruby"],"created_at":"2024-11-30T07:14:47.649Z","updated_at":"2026-01-30T22:05:40.039Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lite::Decorator\n\n[![Gem Version](https://badge.fury.io/rb/lite-decorator.svg)](http://badge.fury.io/rb/lite-decorator)\n[![Build Status](https://travis-ci.org/drexed/lite-decorator.svg?branch=master)](https://travis-ci.org/drexed/lite-decorator)\n\nLite::Decorator is a library for using the decorator pattern to separate view/presentation\nlogic from classes.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lite-decorator'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lite-decorator\n\n## Table of Contents\n\n* [Setup](#setup)\n* [Usage](#usage)\n* [Generator](#generator)\n\n## Setup\n\nDefining a decorator is as simple as inheriting the base class and adding your logic.\n\n```ruby\nclass UserDecorator \u003c Lite::Decorator::Base\n\n  def full_name\n    first_name + ' ' + last_name\n  end\n\nend\n```\n\n## Usage\n\nTo access the decorator you need to pass the object to the decorator class.\nPORO's and ActiveRecord objects can be decorated with this method.\n\n### Instance\n```ruby\nuser = User.first\ndecorator = UserDecorator.new(user)\ndecorator.full_name #=\u003e \"John Doe\"\n```\n\n### Collection\n```ruby\nusers = User.all\ncollection = UserDecorator.new(users)\ncollection.map(\u0026:full_name) #=\u003e [\"John Doe\", \"Jane Poe\"]\n```\n\n### Infered decoration\n\nIncluding the `Inference` module will setup a `decorator_class` and `decorator` method\nthat you can access via your PORO and ActiveRecord objects.\n\n```ruby\nclass User\n  include Lite::Decorator::Inference\nend\n\nuser = User.first\nuser.decorator.full_name\n```\n\n### Decorator delegation\n\nIncluding the `Delegator` module will use method missing to delegate decorator methods as\nif it lived on the PORO or ActiveRecord object itself. If neither the class instance and the\ndecorator contain the method, a `NoMethodError` just like normal.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include Lite::Decorator::Delegator\nend\n\nuser = User.first\nuser.full_name\n```\n\n## Generator\n\nUse `rails g decorator NAME` will generate the following files:\n\n```erb\napp/decorators/[NAME]_decorator.rb\n```\n\nIf an `ApplicationDecorator` file in the `app/decorators` directory is available, the\ngenerator will create file that inherit from `ApplicationDecorator` if not it will\nfallback to `Lite::Decorator::Base`.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/drexed/lite-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 Lite::Decorator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drexed/lite-decorator/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Flite-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-decorator/lists"}