JasonKDarby / stopwatch

0 stars 0 forks source link

Make a map renderer #16

Closed JasonKDarby closed 9 years ago

JasonKDarby commented 9 years ago

There are a few places in ratpack.groovy with code like:

def builder = new JsonBuilder()
builder id: stopwatch.id,
            startTime: stopwatch.startTime.toString(),
            endTime: stopwatch?.endTime?.toString(),
            duration: stopwatch?.duration,
            parentId: stopwatch?.parentId
...
render builder.toPrettyString()

If a field is null it still shows up in the response with a null value and the current implementation isn't DRY. It would be super cool if you could just call:

render stopwatch

and have the renderer call toString() on everything and leave out fields if they are null.