Skip to content

Instantly share code, notes, and snippets.

@SLiNv
Created April 11, 2019 02:22
Show Gist options
  • Save SLiNv/c2e119c60efb31b31b9751b395c45678 to your computer and use it in GitHub Desktop.
Save SLiNv/c2e119c60efb31b31b9751b395c45678 to your computer and use it in GitHub Desktop.
class PathSet #:nodoc:
def find_file(path, prefixes = [], *args)
_find_all(path, prefixes, args, true).first || raise(MissingTemplate.new(self, path, prefixes, *args))
end
private
def _find_all(path, prefixes, args, outside_app)
prefixes = [prefixes] if String === prefixes
prefixes.each do |prefix|
paths.each do |resolver|
if outside_app
templates = resolver.find_all_anywhere(path, prefix, *args)
else
templates = resolver.find_all(path, prefix, *args)
end
return templates unless templates.empty?
end
end
[]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment