rails/jbuilder — pull request #117 by petergoldstein (2013-03-22 04:07:21+00:00)
Title: Add is_a? as an instance method on Jbuilder

This pull request is intended to resolve issue #116 in the simplest way, with the minimal impact on the behavior of the Jbuilder class. This pull request includes:

i) An update to the nested Jbuilder test that causes it to test for the existence of spurious keys in the nested JSON hash and fails against current master
ii) A barebones implementation of is_a? on Jbuilder
iii) A new test to ensure that a user of the Jbuilder library can create a key "is_a?" using the set! method

There's an unfortunate consequence of this change that may or may not be acceptable - a user can no longer call is_a? on a builder object to create a key 'is_a?' in the JSON. This seemed like a reasonable tradeoff to me, but others may certainly feel differently.

Even given this consequence, this pull request seems like the simplest way to resolve issue #116.