{"id":23762180,"url":"https://github.com/rosylilly/partitional","last_synced_at":"2025-09-07T18:45:42.886Z","repository":{"id":56887499,"uuid":"126718460","full_name":"rosylilly/partitional","owner":"rosylilly","description":"Provides partial model to your Rails","archived":false,"fork":false,"pushed_at":"2021-11-22T08:28:56.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-28T06:30:31.949Z","etag":null,"topics":["ruby","ruby-gem","ruby-on-rails"],"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/rosylilly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-25T16:46:42.000Z","updated_at":"2023-02-04T02:53:14.000Z","dependencies_parsed_at":"2022-08-21T00:50:46.071Z","dependency_job_id":null,"html_url":"https://github.com/rosylilly/partitional","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rosylilly/partitional","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosylilly%2Fpartitional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosylilly%2Fpartitional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosylilly%2Fpartitional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosylilly%2Fpartitional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rosylilly","download_url":"https://codeload.github.com/rosylilly/partitional/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosylilly%2Fpartitional/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273722727,"owners_count":25156300,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-12-31T21:16:49.764Z","updated_at":"2025-09-05T06:31:48.164Z","avatar_url":"https://github.com/rosylilly.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Partitional\n\n[![Gem](https://img.shields.io/gem/v/partitional.svg)](https://rubygems.org/gems/partitional)\n[![Build Status](https://travis-ci.org/rosylilly/partitional.svg?branch=master)](https://travis-ci.org/rosylilly/partitional)\n[![Coverage Status](https://coveralls.io/repos/github/rosylilly/partitional/badge.svg?branch=master)](https://coveralls.io/github/rosylilly/partitional?branch=master)\n\nProvides partial model to your Rails. Partial models are like a value object. You can add accessor, domain logics and validation to partial models.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'partitional'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\n```ruby\nclass ApplicationRecord\n  include Partitional # Add this line to `app/models/application_record.rb`\nend\n```\n\n### Example: E-Mail partition\n\n```ruby\n# app/models/user.rb\nclass User \u003c ApplicationRecord\n  # `users` table has :email_local_part and :email_domain columns\n  parition :email, prefix: :email # or mapping: { local_part: :email_local_part, domain: :email_domain }\nend\n\n# app/models/company.rb\nclass Company \u003c ApplicationRecord\n  # `companies` table has :contact_email_local_part, :contact_email_domain\n  # :payment_email_local_part and :payment_email_domain columns\n\n  partition :contact_email, class_name: 'Email', prefix: :contact_email\n  partition :payment_email, class_name: 'Email', prefix: :payment_email\nend\n\n# app/models/email.rb\nclass Email \u003c Partitional::Model\n  attr_accessor :local_part, :domain\n\n  validates :local_part, format: /\\A[a-zA-Z0-9_-]{1,255}\\z/\n  validates :domain, format: /\\A[a-zA-Z0-9]{2,}(?:\\.[a-zA-Z0-9]{2,})+\\z/\n\n  def to_s\n    \"#{local_part}@#{domain}\"\n  end\nend\n\n# in some code\nuser = User.find(1)\nuser.email.local_part = \"test\"\nuser.email.domain = \"example.com\"\nuser.valid? # =\u003e true\n\nuser.email.domain = \"!!!!\"\nuser.valid? # =\u003e false\n```\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/rosylilly/partitional.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosylilly%2Fpartitional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosylilly%2Fpartitional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosylilly%2Fpartitional/lists"}