steveklabnik / sunlight-congress

A wrapper for the Sunlight Foundation's Congress API
https://github.com/steveklabnik/sunlight-congress
MIT License
36 stars 27 forks source link

Make method calls chainable #24

Open thenickcox opened 11 years ago

thenickcox commented 11 years ago

As Joe and I were implementing the Vote functionality, we realized that in the API calls, queries can be chained. For example,

/hearings?query=environment&chamber=senate

Unfortunately, we only implemented each attribute of the vote object returned individually. It looks like the Bill class was implemented the same way. We weren't immediately sure of how to make the methods chainable, because we would have to build up the API call out of strings that the methods returned, etc...we just decided to punt on that for now. How were we thinking of doing that, or has anyone broached that topic?

steveklabnik commented 11 years ago

Haven't thought about it at all. Seems like it makes even more sense to move in the 'objects' direction rather than the 'class method' direction we started with.

joeyjoejoejr commented 11 years ago

I'm curious about what you mean by 'moving in the objects direction'? I feel like having the query methods as class methods seems mirror what I would expect from ORMs.

If these search terms are also somehow chain-able it seems like it might solve the, pagination issues with other models as well if you can just tack the page number and number of results on that chain.

steveklabnik commented 11 years ago

I was talking about https://github.com/steveklabnik/sunlight-congress/pull/16 , but be warned: I have pretty extreme jetlag at the moment. ;)