attr_json: Very smooth models-within-models serialized to json in ActiveRecord

Hey, I wrote a gem that lets you have attributes in an ActiveRecord model serialize to keys in a json hash serialized to Json. It supports casting/typing just like AR, arrays, models-within-models, form builders (including treating models-within-arrays-and-models like you treat associations), dirty tracking on a per-attribute basis for json-serialized attributes, and some very basic querying support (also across models-within-models).

It was possible, in surprisingly few lines of code and working so consistently with “normal” AR, only cause of the awesome work sgriffin and others did on the Attributes API stuff, and other Rails “internal” APIs. Rails gets a lot of complaints for it’s architecture and legacy code (some deserved), but there’s increasingly some really nice architecture in there to build off of.

So, you, dear reader, may be interested:

https://github.com/jrochkind/attr_json

Feedback of any sort very welcome.

Jonathan