-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fog::Collection doesn't fetch while converted by Kernel.Array method #277
Comments
Thanks for the detailed report. No, I do not think that is intended/expected. You can see here how we attempted at least to replace default Array behaviors with the lazy_load followed by doing the normal array behavior (which seems to work for many, but as you point out not all of the methods): fog-core/lib/fog/core/collection.rb Lines 12 to 34 in e359e66
It's also possible that this may have worked in earlier versions of ruby and implementation differences have introduced this. Just speculating here, but it seems surprising to me that we wouldn't have stumbled upon this earlier. Not that it matters too much one way or the other. I'd certainly welcome ideas on how we might fix this discrepancy if you have thoughts. |
Thanks geemus. Frankly, I think the proper solution is making Fog::Collection an Enumerable, not inheriting Array. Most Array methods are provided by Enumerable so this will work well in most cases I suppose. How do you think? |
It's an interesting idea for sure. I suspect that might in fact be a cleaner solution, but I am definitely worried about breaking changes. Given how much usage there already is for this (and how few reports there seem to have been of this problem) it might be more trouble than it is worth, even if this solution might be better. Does that make sense? What do you think? |
This issue has been marked inactive and will be closed if no further activity occurs. |
Hi.
I found out that Fog::Collection donsn't do
lazy_load
while being converted byKernel.Array
method that implicitly called by several Array methods.For example,
Array#concat
converts its operand byArray()
and Fog::Collection instance passed toArray#concat
won't dolazy_load
so an empty array will be concatinated.This causes making
flat_map
(this internally usesArray#concat
to gather the results) over Fog::Collections generate empty results.It works well by manually calling
all
to load explicitly.This is intentional? I think this behavior is bit confusable IMHO.
The text was updated successfully, but these errors were encountered: