d6bf2137af0e3b6f523a58228ac18e6e6e727454
1 module ActionView
#:nodoc:
2 class PathSet
< Array
#:nodoc:
3 def self.type_cast(obj
)
5 if Base
.warn_cache_misses
&& defined?(Rails
) && Rails
.initialized
?
6 Base
.logger
.debug
"[PERFORMANCE] Processing view path during a " +
7 "request. This an expense disk operation that should be done at " +
8 "boot. You can manually process this view path with " +
9 "ActionView::Base.process_view_paths(#{obj.inspect}) and set it " +
19 super(*args
).map
! { |obj
| self.class.type_cast(obj
) }
23 super(self.class.type_cast(obj
))
27 super(array
.map
! { |obj
| self.class.type_cast(obj
) })
30 def insert(index
, obj
)
31 super(index
, self.class.type_cast(obj
))
35 super(*objs
.map
{ |obj
| self.class.type_cast(obj
) })
39 super(*objs
.map
{ |obj
| self.class.type_cast(obj
) })
43 def self.eager_load_templates
!
44 @eager_load_templates = true
47 def self.eager_load_templates
?
48 @eager_load_templates || false
51 attr_reader
:path, :paths
52 delegate
:to_s, :to_str, :hash, :inspect, :to => :path
54 def initialize(path
, load
= true)
55 raise ArgumentError
, "path already is a Path class" if path
.is_a
?(Path
)
69 raise "Unloaded view path! #{@path}" unless @loaded
74 @loaded ? true : false
78 reload
! unless loaded
?
82 # Rebuild load path directory cache
86 templates_in_path
do |template
|
87 # Eager load memoized methods and freeze cached template
88 template
.freeze
if self.class.eager_load_templates
?
90 @paths[template
.path
] = template
91 @paths[template
.path_without_extension
] ||= template
100 (Dir
.glob("#{@path}/**/*/**") | Dir
.glob("#{@path}/**")).each
do |file
|
101 unless File
.directory
?(file
)
102 yield Template
.new(file
.split("#{self}/").last
, self)
109 each
{ |path
| path
.load
}
113 each
{ |path
| path
.reload
! }
116 def [](template_path
)
118 if template
= path
[template_path
]