Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Memoize objects #1

Open
michaelbaudino opened this issue Feb 10, 2016 · 0 comments
Open

Memoize objects #1

michaelbaudino opened this issue Feb 10, 2016 · 0 comments

Comments

@michaelbaudino
Copy link
Member

We should memoize already downloaded objects.
For example, the following snippet should execute only one request to the API:

TimestampAPI::Project.find(123)
TimestampAPI::Project.find(123)

Also, the following snippet should require project 123 only once:

task = TimestampAPI::Project.find(123).tasks.first
task.project

We already do it on an object (calling task.project twice on the same object only trigger one API call), we should do it globally.

Objects could thus be shared, this would be great in the end:

project1 = TimestampAPI::Project.find(1)
project2 = TimestampAPI::Project.find(2)
project1.client === project2.client # => true
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant