Class: MetaERB::TemplateStore
- Inherits:
-
Object
- Object
- MetaERB::TemplateStore
- Defined in:
- lib/meta_erb/template_store.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ TemplateStore
constructor
A new instance of TemplateStore.
- #reset! ⇒ Object
- #search_in(pattern, in_front = true) ⇒ Object
- #template(name) ⇒ Object
Constructor Details
#initialize ⇒ TemplateStore
Returns a new instance of TemplateStore.
12 13 14 15 16 |
# File 'lib/meta_erb/template_store.rb', line 12 def initialize @search_paths = [] @templates = {} @mutex = Mutex.new end |
Class Method Details
.search_in(pattern) ⇒ Object
8 9 10 |
# File 'lib/meta_erb/template_store.rb', line 8 def self.search_in(pattern) shared.search_in(pattern) end |
.shared ⇒ Object
4 5 6 |
# File 'lib/meta_erb/template_store.rb', line 4 def self.shared @template_store ||= MetaERB::TemplateStore.new end |
Instance Method Details
#reset! ⇒ Object
37 38 39 40 41 |
# File 'lib/meta_erb/template_store.rb', line 37 def reset! @mutex.synchronize do @templates = {} end end |
#search_in(pattern, in_front = true) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/meta_erb/template_store.rb', line 18 def search_in(pattern, in_front=true) @mutex.synchronize do pattern = File.(pattern) unless @search_paths.include?(pattern) if in_front @search_paths.unshift(pattern) else @search_paths.push(pattern) end end end end |
#template(name) ⇒ Object
31 32 33 34 35 |
# File 'lib/meta_erb/template_store.rb', line 31 def template(name) @mutex.synchronize do @templates[name.to_sym] || load_template(name) end end |