Class: Tdc::InMemoryDataDefinition

Inherits:
DataDefinition show all
Defined in:
lib/tdc/in_memory_data_definition.rb

Overview

Knows how to read data definitions from an in-memory representation.

Instance Method Summary collapse

Methods inherited from DataDefinition

#with_indifferent_access

Constructor Details

#initialize(path_elements_data = {}) ⇒ InMemoryDataDefinition

Returns a new instance of InMemoryDataDefinition.



6
7
8
# File 'lib/tdc/in_memory_data_definition.rb', line 6

def initialize(path_elements_data = {})
  @store = path_elements_data
end

Instance Method Details

#read(*path_elements) ⇒ Object



10
11
12
13
14
# File 'lib/tdc/in_memory_data_definition.rb', line 10

def read(*path_elements)
  @store.fetch(path_elements) do
    raise Tdc::FatalError, "The path did not have any data associated with it: #{path_elements.inspect}"
  end
end

#store(path_elements, data) ⇒ Object



16
17
18
# File 'lib/tdc/in_memory_data_definition.rb', line 16

def store(path_elements, data)
  @store[path_elements] = data
end