ActiveResource with a Database??

To start off, I don't know if this is unorthodox, or if someone has had to implement something similar. I've searched all over Google and don't really a see a good solution for what I'm trying to do.

Basically I created my own plugin that subclasses ActiveResource so that I can consume non-REST URIs and get back XML. That's easy, there are lots of exmaples online of how to do that. Basically, I then use a gem called happymapper to bind the XML to Ruby objects. Again, this works very easily as well. Now here's where I'm stuck. I want to persist the Ruby object to a local database so that I don't have to go out and get it again. I had a thought of using the save method from ActiveRecord since all the DB plumbing is built in, but I'm a little bit at a loss as to how I can call ActiveRecords's save method from a subclass of ActiveResource as Ruby doesn't allow multiple inheritance.

Has anyone else needed to use ActiveResource to extract data, and then come up with a method to persist that data to a local DB? Using the ActiveResource save method will attempt to POST it back to the place where I got it, and it's a read-only resource.

Thanks for your help everyone!

David

Depending on the object, serializing (either to YAML or Marshal format) might work. Then you'd just store the whole serialized object (now basically a BLOB) to the DB.

Not sure how well ActiveResource plays with serialization, but it's worth a try.

--Matt Jones