Class: OsCtld::ErbTemplateCache
- Inherits:
-
Object
- Object
- OsCtld::ErbTemplateCache
- Includes:
- Singleton
- Defined in:
- lib/osctld/erb_template_cache.rb
Instance Attribute Summary collapse
-
#templates ⇒ Object
readonly
protected
Returns the value of attribute templates.
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ ERB
-
#initialize ⇒ ErbTemplateCache
constructor
A new instance of ErbTemplateCache.
- #load ⇒ Object
Constructor Details
#initialize ⇒ ErbTemplateCache
Returns a new instance of ErbTemplateCache.
14 15 16 17 |
# File 'lib/osctld/erb_template_cache.rb', line 14 def initialize @templates = {} load end |
Instance Attribute Details
#templates ⇒ Object (readonly, protected)
Returns the value of attribute templates.
36 37 38 |
# File 'lib/osctld/erb_template_cache.rb', line 36 def templates @templates end |
Class Method Details
.[](name) ⇒ Object
7 8 9 |
# File 'lib/osctld/erb_template_cache.rb', line 7 def [](name) instance[name] end |
Instance Method Details
#[](name) ⇒ ERB
30 31 32 |
# File 'lib/osctld/erb_template_cache.rb', line 30 def [](name) templates[name].clone end |
#load ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/osctld/erb_template_cache.rb', line 19 def load templates.clear Dir.glob('**/*.erb', base: OsCtld.template_dir).each do |tpl| content = File.read(File.join(OsCtld.template_dir, tpl)) templates[tpl[0..-5]] = ERB.new(content, trim_mode: '-') end end |