Class: JSONFactory::TemplateStore
- Inherits:
-
Object
- Object
- JSONFactory::TemplateStore
- Includes:
- Singleton
- Defined in:
- lib/json_factory/template_store.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #get(path) ⇒ Object
-
#initialize ⇒ TemplateStore
constructor
A new instance of TemplateStore.
Constructor Details
#initialize ⇒ TemplateStore
Returns a new instance of TemplateStore.
7 8 9 |
# File 'lib/json_factory/template_store.rb', line 7 def initialize @templates = {} end |
Instance Method Details
#clear ⇒ Object
19 20 21 |
# File 'lib/json_factory/template_store.rb', line 19 def clear @templates.clear end |
#get(path) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/json_factory/template_store.rb', line 11 def get(path) if @templates.key? path @templates.fetch(path) else @templates.store(path, read_template(path)) end end |