fcoury / octopi

A Ruby interface to GitHub API v2
http://hasmany.info/2009/4/18/ruby-interface-to-github-api
MIT License
216 stars 47 forks source link

Lazily Evaluate Implicit Objects #7

Closed runpaint closed 15 years ago

runpaint commented 15 years ago

Many objects that we create have attributes that imply other objects. For example, the .owner attribute of a repository returns a String representation of the owner's name, but it could more usefully return a User object representing the same user. It would be expensive to handle this naively, so we ideally want an architecture that will automatically instantiate such objects on demand. If the caller just wants the owner's name,return a string; if he wants the owner's e-mail address, create a User object and call the .email method.

We currently handle one of these cases by accepting a parameter specifying whether the caller wants objects or strings for User objects, but given the prevalence of such cases a general, "do the right thing" approach would be optimal.

fcoury commented 15 years ago

I agree 100% and I was going to open the exact same issue.

radar commented 15 years ago

This behaviour has changed and will now load the object based on the given information.