{"id":19821589,"url":"https://github.com/oestrich/nagare","last_synced_at":"2025-05-01T12:31:04.863Z","repository":{"id":56885061,"uuid":"52489153","full_name":"oestrich/nagare","owner":"oestrich","description":"A simple serializer for your Rails API.","archived":false,"fork":false,"pushed_at":"2017-07-20T14:45:12.000Z","size":15,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-31T14:47:07.528Z","etag":null,"topics":["rails-api","ruby","serializer"],"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/oestrich.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}},"created_at":"2016-02-25T02:03:45.000Z","updated_at":"2024-10-28T20:57:03.000Z","dependencies_parsed_at":"2022-08-20T13:00:07.445Z","dependency_job_id":null,"html_url":"https://github.com/oestrich/nagare","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fnagare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fnagare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fnagare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fnagare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oestrich","download_url":"https://codeload.github.com/oestrich/nagare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224256877,"owners_count":17281618,"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":["rails-api","ruby","serializer"],"created_at":"2024-11-12T10:29:34.850Z","updated_at":"2024-11-12T10:29:35.509Z","avatar_url":"https://github.com/oestrich.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nagare 流れ\n\n[![Build Status](https://travis-ci.org/oestrich/nagare.svg?branch=master)](https://travis-ci.org/oestrich/nagare)\n\nNagare is a simple serializer for your Rails API.\n\n## Installation\n\n```ruby\ngem 'nagare', github: 'oestrich/nagare'\n```\n\n## Usage\n\n### Create your context\n\nCreate a specialized context for your application. Anything you place in here will be available inside of the serializers.\n\n```ruby\nclass ApplicationController \u003c ActionController::Base\n  private\n  \n  def nagare_context\n    @nagare_context ||= Nagare::Context.new({\n      current_user: current_user,\n    })\n  end\nend\n```\n\n### Create your serializers\n\nThere are item serializers and collection serializers.\n\n```ruby\nclass OrderSerializer \u003c Nagare::Item\n  attributes :id, :user_id\nend\n```\n\nYou can access the object being serialized by the `object` method.\n\n```ruby\nclass OrdersSerializer \u003c Nagare::Collection\n  attributes :count, :href\n  \n  def count\n    collection.count\n  end\nend\n```\n\nYou can access the collection being serialized by the `collection` method.\n\n### Use your serializers\n\nYou can extend the context per route very easily by specifying a `context` key with a new hash. Hash keys will be available as methods inside of the serializer.\n\n```ruby\nclass OrdersController \u003c ApplicationController\n  def index\n    render({\n      json: orders,\n      serializers: { collection: OrdersSerializer, item: OrderSerializer },\n      context: { href: orders_url },\n    })\n  end\n  \n  def show\n    render({\n      json: order,\n      serializer: { item: OrderSerializer },\n      context: { href: order_url(order) },\n    })\n  end\nend\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foestrich%2Fnagare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foestrich%2Fnagare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foestrich%2Fnagare/lists"}