{"repo":"ruby-grape/grape-entity","free":true,"listed":false,"github":"https://github.com/ruby-grape/grape-entity","clone":"git clone https://github.com/ruby-grape/grape-entity.git","description":"An API focused facade that sits on top of an object model.","language":"Ruby","stars":730,"topics":["api","grape","ruby","entity"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Table of Contents - Grape::Entity - Introduction - Example - Reusable Responses with Entities - Defining Entities - Basic Exposure - Exposing with a Presenter - Conditional Exposure - Safe Exposure - Nested Exposure - Collection Exposure - Merge Fields - Runtime Exposure - Unexpose - Overriding exposures - Returning only the fields you want - Aliases - Format Before Exposing - Expose Nil - Default Value - Documentation - Options Hash - Passing Additional Option To Nested Exposure - Attribute Path Tracking - Using the Exposure DSL - Using Entities - Entity Organization - Caveats - Preloading Associations - Installation - Testing with Entities - Project Resources - Contributing - License - Copyright Grape::Entity Introduction This gem adds Entity support to API frameworks, such as Grape. Grape's Entity is an API focused facade that sits on top of an object model. Example Reusable Responses with Entities Entities are a reusable means for converting Ruby objects to API responses. Entities can be used to conditionally include fields, nest other entities, and build ever larger responses, using inheritance. Defining Entities Entities inherit from Grape::Entity, and define a simple DSL. Exposures can use runtime options to determine which fields should be visible, these options are available to :if , :unless , and :proc . Basic Exposure Define a list of fields that will always be exposed. The field lookup takes several steps first try entity-instance.exposure next try object.exposure","default_branch":null,"files":null,"tree":[],"storefront":"/r/ruby-grape","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ruby-grape/grape-entity/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}