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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

jrochkind-2
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


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8cb844c6-13ce-48a2-a5fc-e19a5e1541a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.