{"id":14956001,"url":"https://github.com/omarluq/activerecord_liquid_drops","last_synced_at":"2025-09-14T08:32:58.885Z","repository":{"id":65954098,"uuid":"603308676","full_name":"omarluq/activerecord_liquid_drops","owner":"omarluq","description":"A ruby gem that adds support for creating liquid language drop class magically for every ActiveRecord model and assign drops as attributes","archived":false,"fork":false,"pushed_at":"2024-02-13T09:57:41.000Z","size":14,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T03:31:14.672Z","etag":null,"topics":["activerecord","liquid","liquid-templating-engine","rails","ruby","ruby-on-rails","shopify"],"latest_commit_sha":null,"homepage":"","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/omarluq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2023-02-18T05:26:38.000Z","updated_at":"2024-11-24T03:17:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"7bb1090b-a737-4570-9ef3-a0ad4eb2bb0f","html_url":"https://github.com/omarluq/activerecord_liquid_drops","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.5,"last_synced_commit":"201b8d4a92f60589bd17880d0e1bd9755ab29b12"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Factiverecord_liquid_drops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Factiverecord_liquid_drops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Factiverecord_liquid_drops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omarluq%2Factiverecord_liquid_drops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omarluq","download_url":"https://codeload.github.com/omarluq/activerecord_liquid_drops/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232962561,"owners_count":18603379,"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":["activerecord","liquid","liquid-templating-engine","rails","ruby","ruby-on-rails","shopify"],"created_at":"2024-09-24T13:12:09.536Z","updated_at":"2025-01-08T02:00:07.998Z","avatar_url":"https://github.com/omarluq.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/activerecord_liquid_drops.svg)](https://badge.fury.io/rb/activerecord_liquid_drops)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)\r\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits\u0026logoColor=white)](https://conventionalcommits.org)\r\n[![unstable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\r\n\r\n# Activerecord_liquid_drops\r\n\r\nIntegrates [Liquid Templating Language](https://github.com/Shopify/liquid) [Drops](https://github.com/Shopify/liquid/wiki/Introduction-to-Drops) to Active Record\r\n\r\n## Installation\r\nAdd this line to your application's Gemfile:\r\n\r\n```ruby\r\ngem \"activerecord_liquid_drops\"\r\n```\r\n\r\nAnd then execute:\r\n```bash\r\n$ bundle\r\n```\r\n\r\nOr install it yourself as:\r\n```bash\r\n$ gem install activerecord_liquid_drops\r\n```\r\n\r\n\r\n## Usage\r\n\r\n### Streamlined Drops Definition\r\n\r\nLeveraging the Liquid language and its Drops functionality offers significant advantages in terms of templating engine flexibility. However, the management of numerous Drops classes, often containing boilerplate code, can become cumbersome and unwieldy. `activerecord_liquid_drops` addresses this by automating the creation of Drops classes for each Active Record model seamlessly.\r\n\r\nDefining safe attributes for exposure becomes straightforward. Take our User model with three database columns: `first_name`, `last_name`, and `dob`. To expose these as safe attributes, we simply add a Drops block and pass it symbols representing the columns.\r\n\r\n```ruby\r\nclass User \u003c ActiveRecord::Base\r\n  drops :first_name, :last_name, :dob\r\nend\r\n```\r\n\r\nAdditionally, the Drops block can accept a method name defined on the model, providing even greater customization and control over your data presentation.\r\n\r\n```ruby\r\nclass User \u003c ActiveRecord::Base\r\n  drops :name, :dob\r\n\r\n  def name\r\n    \"#{first_name} #{last_name}\"\r\n  end\r\nend\r\n```\r\n\r\nAssociations are supported as well. If we add a `posts` table to our example with `title` and `body` columns, we can include them in the Drops.\r\n\r\n```ruby\r\nclass User \u003c ActiveRecord::Base\r\n  has_many :posts\r\n  drops :name, :dob\r\n\r\n  def name\r\n    \"#{first_name} #{last_name}\"\r\n  end\r\nend\r\n\r\nclass Post \u003c ActiveRecord::Base\r\n  belongs_to :user\r\n  drops :user, :title, :body\r\nend\r\n```\r\n\r\nIt's important to note that by introducing the `user` association as a drop on the `Post` class, the `Post` drops will inherit those of the user, resulting in `['title', 'body', 'user.name', 'user.age']`.\r\n\r\n### Useful Helpers\r\n\r\nWe've included two helpful helpers:\r\n\r\n1. **`all_drops`**: This class method is added to your Active Record models, making it easy to retrieve an array containing all available Drops for the model.\r\n\r\n   ```ruby\r\n   =\u003e Post.all_drops\r\n   =\u003e ['title', 'body', 'user.name', 'user.age']\r\n   ```\r\n\r\n2. **`drops`**: This instance method is available in your Active Record models, allowing you to instantiate a Drops class instance for your current model instance.\r\n\r\n   ```ruby\r\n   =\u003e post = Post.create!(title: 'New Post', body: 'I hold an affinity for Ruby!!!')\r\n   =\u003e post.drops\r\n   =\u003e PostDrops\r\n   ```\r\n\r\nThese features significantly simplify the management of Drops within your application, streamlining the process and enhancing flexibility.\r\n## Contributing\r\nFork it ( https://github.com/omarluq/activerecord_liquid_drops/fork )\r\n\r\nCreate your feature branch (git checkout -b my-new-feature)\r\n\r\nCommit your changes (git commit -am 'feat: add some feature')\r\n\r\nPush to the branch (git push origin my-new-feature)\r\n\r\nCreate a new Pull Request\r\n\r\n## License\r\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomarluq%2Factiverecord_liquid_drops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomarluq%2Factiverecord_liquid_drops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomarluq%2Factiverecord_liquid_drops/lists"}