Class: Superfluid::Systems::Memory

Inherits:
Data
  • Object
show all
Defined in:
lib/superfluid/systems/memory.rb

Overview

An in-memory file system for storing templates.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#templatesObject (readonly)

Returns the value of attribute templates

Returns:

  • (Object)

    the current value of 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