ruby-grape / grape-rabl

Use rabl with grape
MIT License
136 stars 29 forks source link

Use Grape formatter syntax instead of monkey-patching. #6

Closed dblock closed 11 years ago

dblock commented 11 years ago

This will work with the next release of Grape. We have refactored formatters in order to enable complete control of output by external libraries without having to monkey-patch Grape. This is hopefully a bit cleaner.

The updated syntax is now as follows:

formatter :json, Grape::Formatter::Rabl

The formatter implementation will fallback to Grape's JSON formatter.

See https://github.com/intridea/grape/issues/44 as well.

LTe commented 11 years ago

@dblock thanks!

guilherme commented 10 years ago

isn't strange to assume the default formmater is the JSON formatter? instead of the user defined formatter?

dblock commented 10 years ago

@guilherme I am not sure I understand the question, could you please elaborate? Thx.

guilherme commented 10 years ago

i've misunderstand this:

formatter :json, Grape::Formatter::Rabl

it means that the formatter for JSON is Grape::Formatter::Rabl, if its not possible to use it it will fallback to the default.

I was thinking about it would be possible to do something:

formatter :xml, Grape::Formatter::Rabl

In this case the fallback would be the xml default formatter, but it doesnt make any sense.

sorry for taking your time.