rails / activeresource

Connects business objects and REST web services
MIT License
1.33k stars 362 forks source link

[Feature Request] Lazy Loading Chained `where` calls #408

Open jlurena opened 1 week ago

jlurena commented 1 week ago

Summary

I would like assistance implementing lazy HTTP calls for Collections.

Currently doing something like this:

# This makes two API calls.
result = MyActiveResourceModel.where(first_name: "John").where(last_name: "Doe")

Ideal scenario would be that:

# This makes 0 API call
result = MyActiveResourceModel.where(first_name: "John").where(last_name: "Doe")

# This makes 1 API call
result.to_a

# This makes 1 API call
result.any?
jlurena commented 1 day ago

@byroot @rails I created a PR, would you mind having a look?