Dear All,

I'm trying to build a ruby library to communicate with a REST API. I'm
thinking to make it as an abstraction so it can be modular.
for example

the API is structure as RESTful web service which is Rails like

/devices -> list all device
/devices/12 -> show specific device
/documents
/documents/14

etc.

The problem that I'm facing it structuring the library with module and
class. I wanted to make something like

client = MyLibrary.new user: 'user', password: 'password'

array_of_devices = client.devices.all -> GET /device
devies = client.device.create -> POST /device
device = client.device.get(1) -> GET /device/1

document = client.document.new(device)
document.save

and maybe in the future
document.device -> will return the device where the document belongs to

etc.

first of all is storing the config (user and password) because all of the
api needed this. My question is how to I structure it.

client.devices will return module or class ?
and how to share config variable with the other class or module within the
library.

If you have like a resource, book or maybe a project that go into the
detail of designin API library especially with REST that would help me a
lot and appreciate it.

Thank you very much

Ahmy Yulrizka

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to