balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

Statically generate resource URL's from the marketplace_uri #46

Closed ajsharp closed 12 years ago

ajsharp commented 12 years ago

This PR is primarily a performance enhancement. The change introduced in f3df3ae changes resource URL generation from using properties returned by the Balanced::Marketplace.my_marketplace method to statically building URL's based upon the marketplace URI, which is now cached. So, instead of relying on the GET /v1/marketplaces/:id call to give a url like /v1/marketplaces/:marketplace_id/accounts, we simply construct this string in the code if we have the marketplace_uri available.

We discussed memoizing the entire .my_marketplace method, but there are dynamic properties returned in that response that make that solution infeasible.

ajsharp commented 12 years ago

@mahmoudimus @matin @mjallday Would love to get your thoughts on this stuff.

mahmoudimus commented 12 years ago

Thanks for this Alex. I've reviewed it and I think it's good to go.