Class: RedfishTools::DataStore

Inherits:
Object
  • Object
show all
Defined in:
lib/redfish_tools/datastore.rb

Defined Under Namespace

Classes: Resource

Instance Method Summary collapse

Constructor Details

#initialize(base_path) ⇒ DataStore

Returns a new instance of DataStore.



9
10
11
12
13
14
15
# File 'lib/redfish_tools/datastore.rb', line 9

def initialize(base_path)
  @base_path = File.expand_path(base_path)
  @overlay = {}

  root_file = File.join(@base_path, "redfish", "v1", "index.json")
  raise "Invalid recording folder" unless File.file?(root_file)
end

Instance Method Details

#get(id) ⇒ Object



17
18
19
20
# File 'lib/redfish_tools/datastore.rb', line 17

def get(id)
  id = id.chomp("/")
  @overlay[id] = @overlay.fetch(id, load_resource(id))
end

#set(id, body, headers: nil, time: nil, parent: nil) ⇒ Object



22
23
24
# File 'lib/redfish_tools/datastore.rb', line 22

def set(id, body, headers: nil, time: nil, parent: nil)
  @overlay[id] = Resource.new(id, body, headers, time, parent)
end