signatureio/digitalocean — pull request #3 by PeteMichaud (2013-09-06 17:23:54+00:00)
Title: Expanded to include more of the API

I added new methods to the Image class, and added new Domain and Records classes.

Records probably isn't ideal. Records live under Domains, so it would be nice if you could interact with them through an instance of Domain. To make that work without totally rewriting everything, you'd probably have to make Domain a subclass of RecursiveOpenStruct, then instantiate Domains in the Domain.find and Domain.create methods, and get really clever about instantiating an array of domain objects in the Domain.all method.

The class itself would have to persist the domain_id then, then you could make an AR-like api, eg:

domain = Domain.all.first

domain.records # like Record.all(domain_id)
domain.records(id)
domain.create_record
domain.edit_record
domain.destroy_record

But that wouldn't be quite right either, because if you made it AR-like, people would expect to be able to do stuff like

domain.records << Record.new

This was a can of worms I didn't want to open, so instead I opted for just using the same pattern as all the rest for the Record class, except you have to pass in a domain_id as the first argument of the methods.