RubyGems Navigation menu

lazy_as_json 0.1.0

Lazy As Json A simple and concise way to use as_json with “only”, “except” and other options without using them literally. Instead of using this - `User.as_json(only: [:id, :first_name, profiles: [:company, :location]])` You can perhaps use this - `User.as_json(only_keys: ‘_,first_name,profiles(p),p.company,p.location’)` As simple as this. You can control what your API response should include through a flexible parameter string. i.e. - “/api/v1/users/me?_keys=_,last_name,profiles(p),p.company,p.location” This parameter string could dig through the nested objects and their nesting too. Just to reduce the API response size significantly, you can use this parameter control over wherever it is used. However it might seems quite trivial but frankly speaking it saves lot in response data hence faster loading time at client side. Moreover as it uses Hash.new and constructs attribute on runtime, you can throttle calling from the expensive method by using this parameter string.

Gemfile:
= Copiar al portapapeles ¡Copiado!

instalar:
=

Versiones:

  1. 0.1.0 - March 28, 2016 (9,5 KB)

dependencias de Development (3):

bundler ~> 1.11
rake ~> 10.0
rspec ~> 3.0

Propietarios:

Autores:

  • nhm tanveer hossain khan

SHA 256 checksum:

b7b86e6e0f8a15bb0680173fc51caf61a80d6dd45f954f65ed336252c87faf7f

Total de descargas 3.422

Para esta versión 3.422

Licencias:

N/A

Versión de Ruby requerida: >= 0

Enlace: