Easy and DRY API responses in Ruby
The gem acts_as_api provides a simple interface to determine the representation of your model data, that should be rendered in your API responses. It’s been around for some months, time to update the documentation: Gem
Getting Started Page
Wiki
Comments
Interesting, I like the approach. Have to think about whether I feel I prefer these declarations in model or in the views as in my gem RABL. On the fence. In some cases my APIs still seem less closely tied to the model such that I would prefer view templates but I can see other use cases where the model-centric approach makes sense. Nice gem.
Thanks for your feedback. :) I’m working on a solution to outsource the templates into modules that can be kept in
/app/api_templatesand then be included in a model.Post a comment