Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Split find/find_all apis #31

Merged
merged 1 commit into from Apr 3, 2014
Merged

Split find/find_all apis #31

merged 1 commit into from Apr 3, 2014

Conversation

josh
Copy link
Contributor

@josh josh commented Apr 3, 2014

Trail#find was amended in 94d6727 to take a block and return all matching results. Its okay, but it overloaded find. Really this should have a been a separate method.

This splits that behavior into Trail#find_all. And now that we are at least on 1.9.3, we can take more advantages of the enumerator api additions.

# always returns immediately with enumerator
trail.find_all("application.js")

# same as find(), just grab the first match
# enumerating is lazy, so its just as efficient 
trail.find_all("application.js").first

# in Ruby 2.0 we can use lazy
trail.find_all("application.js").lazy.select { |path| path =~ /custom constraint/ }.first

josh added a commit that referenced this pull request Apr 3, 2014
@josh josh merged commit d3bafe6 into master Apr 3, 2014
@josh josh deleted the find-enum branch April 3, 2014 04:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant