# frozen_string_literal: truemoduleActionView# :nodoc:# = Action View PathSet## This class is used to store and access paths in Action View. A number of# operations are defined so that you can search among the paths in this# set and also perform operations on other +PathSet+ objects.## A +LookupContext+ will use a +PathSet+ to store the paths in its context.classPathSet# :nodoc:includeEnumerableattr_reader:pathsdelegate:[],:include?,:pop,:size,:each,to: :pathsdefinitialize(paths=[])@paths=typecastpathsenddefinitialize_copy(other)@paths=other.paths.dupselfenddefto_arypaths.dupenddefcompactPathSet.newpaths.compactenddef+(array)PathSet.new(paths+array)end%w(<< concat push insert unshift).eachdo|method|class_eval<<-METHOD,__FILE__,__LINE__+1
def #{method}(*args)
paths.#{method}(*typecast(args))
end
METHODenddeffind(path,prefixes,partial,details,details_key,locals)find_all(path,prefixes,partial,details,details_key,locals).first||raise(MissingTemplate.new(self,path,prefixes,partial,details,details_key,locals))enddeffind_all(path,prefixes,partial,details,details_key,locals)search_combinations(prefixes)do|resolver,prefix|templates=resolver.find_all(path,prefix,partial,details,details_key,locals)returntemplatesunlesstemplates.empty?end[]enddefexists?(path,prefixes,partial,details,details_key,locals)find_all(path,prefixes,partial,details,details_key,locals).any?endprivatedefsearch_combinations(prefixes)prefixes=Array(prefixes)prefixes.eachdo|prefix|paths.eachdo|resolver|yieldresolver,prefixendendenddeftypecast(paths)paths.mapdo|path|casepathwhenPathname,StringFileSystemResolver.newpath.to_selsepathendendendendend