Class: Superfluid::Systems::Memory
- Inherits:
-
Data
- Object
- Data
- Superfluid::Systems::Memory
- Defined in:
- lib/superfluid/systems/memory.rb
Overview
An in-memory file system for storing templates.
Instance Attribute Summary collapse
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
-
#initialize(templates: {}) ⇒ Memory
constructor
A new instance of Memory.
- #read_template_file(name) ⇒ Object
- #register(name, content) ⇒ Object
Constructor Details
#initialize(templates: {}) ⇒ Memory
Returns a new instance of Memory.
7 8 9 |
# File 'lib/superfluid/systems/memory.rb', line 7 def initialize templates: {} super end |
Instance Attribute Details
#templates ⇒ Object (readonly)
Returns the value of attribute templates
6 7 8 |
# File 'lib/superfluid/systems/memory.rb', line 6 def templates @templates end |
Instance Method Details
#read_template_file(name) ⇒ Object
16 17 18 |
# File 'lib/superfluid/systems/memory.rb', line 16 def read_template_file name templates.fetch(name) { fail Liquid::FileSystemError, "Template not found: #{name}." } end |
#register(name, content) ⇒ Object
11 12 13 14 |
# File 'lib/superfluid/systems/memory.rb', line 11 def register name, content templates[name.to_s] = content self end |