{"id":18103294,"url":"https://github.com/wantedly/pb-serializer","last_synced_at":"2025-10-06T09:31:14.295Z","repository":{"id":48788325,"uuid":"246309035","full_name":"wantedly/pb-serializer","owner":"wantedly","description":"Serialize Ruby objects to Protocol Buffers","archived":false,"fork":false,"pushed_at":"2024-08-06T09:05:52.000Z","size":119,"stargazers_count":16,"open_issues_count":5,"forks_count":3,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-01-20T00:54:46.277Z","etag":null,"topics":["grpc","protocol-buffers","rails","resource-serializer","ruby","ruby-on-rails","serialization"],"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/wantedly.png","metadata":{"files":{"readme":"README.ja.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}},"created_at":"2020-03-10T13:32:00.000Z","updated_at":"2024-08-06T07:17:05.000Z","dependencies_parsed_at":"2022-08-31T12:50:23.214Z","dependency_job_id":null,"html_url":"https://github.com/wantedly/pb-serializer","commit_stats":null,"previous_names":["izumin5210/pb-serializer"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fpb-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fpb-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fpb-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fpb-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wantedly","download_url":"https://codeload.github.com/wantedly/pb-serializer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515426,"owners_count":19002481,"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":["grpc","protocol-buffers","rails","resource-serializer","ruby","ruby-on-rails","serialization"],"created_at":"2024-10-31T22:11:40.037Z","updated_at":"2025-10-06T09:31:08.950Z","avatar_url":"https://github.com/wantedly.png","language":"Ruby","readme":"\u003c!--\n# @title 日本語版 README\n--\u003e\n\n# Pb::Serializer\n\n`Pb::Serializer` はRuby オブジェクトの Protocol Buffers シリアライザです。\n\n[English version](./README.md)\n\n## Features\n\n- [ActiveModelSerializers](https://github.com/rails-api/active_model_serializers) のような宣言的な API \n- [Well-Known Types](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf) への自動変換（例 `google.protobuf.Uint64Value`）\n- [`google.protobuf.FieldMask`](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask) を利用した、GraphQL のような選択的フィールド取得のサポート\n  - [ComputedModel](https://github.com/wantedly/computed_model) と組み合わせることで、複雑なロジックと依存関係を持つ API も宣言的に実装できます\n\n\n## Usage\n\n以下のような Protocol Buffers のメッセージ定義および ActiveRecord モデルを例にします。\n\n```proto\nsyntax = \"proto3\";\n\npackage example;\n\noption ruby_package = \"ExamplesPb\";\n\nmessage User {\n  uint64 id = 1;\n  string name = 2;\n}\n```\n\n```ruby\n# Schema: [id(integer), name(string)]\nclass User \u003c ActiveRecord::Base\nend\n```\n\n`.proto` で定義された `User` メッセージに対応する PbSerializer を実装します。\n生成されたクラスと定義されているフィールドすべてを PbSerializer に宣言する必要があります。\n\n```ruby\nclass UserPbSerializer \u003c Pb::Serializer::Base\n  message ExamplesPb::User\n\n  attribute :id\n  attribute :name\nend\n```\n\n実装した PbSerializer で、Ruby オブジェクトを protobuf message object にシリアライズできます。\n\n```ruby\nuser = User.find(123)\nUserPbSerializer.new(user).to_pb\n# =\u003e \u003cExamplesPb::User: id: 123, name: \"someuser\"\u003e\n```\n\n各 attribute の値は、PbSerializer インスタンス、もしくはコンストラクタに渡されたオブジェクト から決定されます。\n\n## Next read\n\n- [Examples](./docs/examples.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwantedly%2Fpb-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwantedly%2Fpb-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwantedly%2Fpb-serializer/lists"}