Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Shouldn't Collection.to_ary() return an array? #432

Closed
mahemoff opened this Issue · 2 comments

2 participants

@mahemoff

Slightly pedantic, but shouldn't to_ary() itself be returning Array or a subclass of Array? (to_a() does the job of converting to array, but I wasn't expecting to_ary() to return self.)

@karmi
Owner

Hmm, good question. Not sure myself :) It just returns the collection, which is Enumerable-based/compatible, basically just because Rails calls to_ary in views, as far as I remember. It could probably return the underlying @results. Fancy a test case / run withing Rails?

@karmi
Owner

The ActionView::PartialRenderer#collection calls to_ary when you render :collection => @results. I think it's safer here to return the wrapper, not the raw results array in case we need to decorate that. Also, don't have time to test it extensively in real-world apps.

@karmi karmi closed this
@karmi karmi referenced this issue from a commit
Brandon Istenes [FIX] Make Tire::Results::Collection#to_ary return an Array
Closes #718, closes #432
e23bf6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.