{"id":22144158,"url":"https://github.com/mikeheft/dry_serialization","last_synced_at":"2025-07-02T08:06:36.977Z","repository":{"id":40089640,"uuid":"242746709","full_name":"mikeheft/dry_serialization","owner":"mikeheft","description":"Simple gem to dry up some of the responses for success \u0026 error responses for different gems. Also has a new feature to deserialize the json api spec payload into a format acceptable for Rails' mass assignment","archived":false,"fork":false,"pushed_at":"2023-03-08T20:49:31.000Z","size":87,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T12:15:05.297Z","etag":null,"topics":["blueprinter","json-api","jsonapi-serializer","serialization","serializer","serializers"],"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/mikeheft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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},"funding":{"github":null,"patreon":"mikeyduece","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-02-24T13:43:28.000Z","updated_at":"2021-06-02T12:58:00.000Z","dependencies_parsed_at":"2024-04-19T13:09:19.061Z","dependency_job_id":null,"html_url":"https://github.com/mikeheft/dry_serialization","commit_stats":null,"previous_names":["mikeheft/dry_serialization"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/mikeheft/dry_serialization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeheft%2Fdry_serialization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeheft%2Fdry_serialization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeheft%2Fdry_serialization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeheft%2Fdry_serialization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikeheft","download_url":"https://codeload.github.com/mikeheft/dry_serialization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeheft%2Fdry_serialization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263099439,"owners_count":23413622,"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":["blueprinter","json-api","jsonapi-serializer","serialization","serializer","serializers"],"created_at":"2024-12-01T22:19:07.943Z","updated_at":"2025-07-02T08:06:36.954Z","avatar_url":"https://github.com/mikeheft.png","language":"Ruby","funding_links":["https://patreon.com/mikeyduece"],"categories":[],"sub_categories":[],"readme":"# DrySerialization\n\n[![Gem Version](https://badge.fury.io/rb/dry_serialization.svg)](https://badge.fury.io/rb/dry_serialization)\n![GitHub issues](https://img.shields.io/github/issues-raw/mikeyduece/dry_serialization?style=plastic)\n\nSimple gem to dry up your controllers and provide a uniform interface for serializing Ruby objects. It relys on you to select and install either the blueprinter or jsonapi-serializer gems as well as this one.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'dry_serialization'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install dry_serialization\n\n## Usage\n\n- Install with rails generator\n  * currently supported serializers are [jsonapi_serializer](https://github.com/jsonapi-serializer/jsonapi-serializer) and [blueprinter](https://github.com/procore/blueprinter)\n  \n\n    `rails g dry_serialization:\u003cserializer_name\u003e:install`\n    \n\n- This generator will assume you have an api controller, and create one if you do not. This is to further keep the api separate from the web controllers. \n  - The inclusion of the module corresponding to your chosen serializer gem will give you access to `#serialized_resource`.\n    - The `#serialized_resource` method also takes an optional 'options' hash. For `jsonapi-serializer`, that can come in the form of the `include` hash and/or `meta` or any of the other options available through that gem. Please see their documentation for all options.\n    - Similarly for `blueprinter` it will also take an optional options hash. Again, please see the official documentation in their repo.\n- Conversly, if you choose to not use the install generator, you can simply add your desired serializer gem to the Gemfile and include the relevant modules where needed.\n  ```ruby\n  user = User.find(params[:id])\n  render json: serialized_resource(user, UserSerializer) # UserSerializer can be substituted with UserBlueprint if that is the gem you've chosen.\n  ```\n  \n- SerializationHelper\n  - This module provides success and error response helper methods. \n  - In your controller you can use them like so:\n  ```ruby\n  def create\n    user = User.create(create_user_params)\n    return error_response(user.errors) unless user.errors.empty?\n    \n    success_response(user, UserSerializer, :created)\n  end\n  ```\n  - Both methods take an optional argument for the status. You can either use the symbol representation or the number code.\n    \n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. 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/mikeyduece/dry_serialization.\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%2Fmikeheft%2Fdry_serialization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeheft%2Fdry_serialization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeheft%2Fdry_serialization/lists"}