# 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?,:size,:each,to: :pathsdefinitialize(paths=[])@paths=typecast(paths).freezeenddefinitialize_copy(other)@paths=other.paths.dup.freezeselfenddefto_arypaths.dupenddefcompactPathSet.newpaths.compactenddef+(other)array=Array===other?other:other.pathsPathSet.new(paths+array)enddeffind(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,String# This path should only be reached by "direct" users of# ActionView::Base (not using the ViewPaths or Renderer modules).# We can't cache/de-dup the file system resolver in this case as we# don't know which compiled_method_container we'll be rendering to.FileSystemResolver.new(path)whenResolverpathelseraiseTypeError,"#{path.inspect} is not a valid path: must be a String, Pathname, or Resolver"endendendendend